cancel
Showing results for 
Search instead for 
Did you mean: 

Problem looking up entity local home - ejb-local-ref

0 Kudos
194

Hi,

I have an application with a session bean (MetaManager) and an entity bean (InfoItem) which I want to reference from that session bean. The entity

bean is deployed correctly, but I simply cannot look it up locally from the session bean (the remote lookup works alright).

I use the following code for the lookup:

Context initial = new InitialContext();

InfoItemLocalHome home = (InfoItemLocalHome)initial.lookup("sap.com/ejb/InfoItemLocal");

The following exception is thrown:

com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of InfoItemLocal.

In ejb-jar.xml I have specified MetaManagerBean as follows:

<session>

<ejb-name>MetaManagerBean</ejb-name>

<home>com.sap.promise.rhl.ssb.MetaManagerHome</home>

<remote>com.sap.promise.rhl.ssb.MetaManager</remote>

<local-home>com.sap.promise.rhl.ssb.MetaManagerLocalHome</local-home>

<local>com.sap.promise.rhl.ssb.MetaManagerLocal</local>

<ejb-class>com.sap.promise.rhl.ssb.MetaManagerBean</ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Container</transaction-type>

<ejb-local-ref>

<ejb-ref-name>InfoItemLocal</ejb-ref-name>

<ejb-ref-type>Entity</ejb-ref-type>

<local-home>com.sap.promise.rhl.entity.InfoItemLocalHome</local-home>

<local>com.sap.promise.rhl.entity.InfoItemLocal</local>

<ejb-link>RhlEjb.jar#InfoItemBean</ejb-link>

</ejb-local-ref>

</session>

In ejb-j2ee-engine.xml I have specified:

<enterprise-bean>

<ejb-name>MetaManagerBean</ejb-name>

<jndi-name>sap.com/ejb/MetaManager</jndi-name>

<ejb-local-ref>

<ejb-ref-name>InfoItemLocal</ejb-ref-name>

<jndi-name>sap.com/ejb/InfoItemLocal</jndi-name>

</ejb-local-ref>

<session-props/>

</enterprise-bean>

The error occurs regardless of whether I use

"InfoItemLocal" (as specified as the ejb-ref-name) or

"sap.com/ejb/InfoItemLocal" (jndi-name).

I simply cannot do a local lookup. Anybody has an idea of what I'm doing wrong?

Thanks alot for your help!

View Entire Topic
0 Kudos

Hi Peter & Maksim,

I have used the code you adviced, but unfortunately I cannot even create the InitialContext. When I start the bundle that contains the code, the

exception stack reads as follows:

-> start file:bundle/devhl.jar

javax.naming.NoInitialContextException: Cannot instantiate class: com.sap.engine

.services.jndi.InitialContextFactoryImpl [Root exception is java.lang.ClassNotFo

undException: com.sap.engine.services.jndi.InitialContextFactoryImpl]

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6

52)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243

)

at javax.naming.InitialContext.init(InitialContext.java:219)

at javax.naming.InitialContext.<init>(InitialContext.java:195)

at com.sap.devhl.cm.Activator.start(Activator.java:104)

at org.ungoverned.oscar.Oscar.startBundleWithStartLevel(Oscar.java:1831)

at org.ungoverned.oscar.Oscar.startBundle(Oscar.java:1721)

at org.ungoverned.oscar.BundleImpl.start(BundleImpl.java:128)

at org.ungoverned.osgi.bundle.shell.StartCommandImpl.execute(StartComman

dImpl.java:101)

at org.ungoverned.osgi.bundle.shell.Activator$ShellServiceImpl.executeCo

mmand(Activator.java:280)

at org.ungoverned.osgi.bundle.shelltui.ShellTuiActivator$ShellTuiRunnabl

e.run(ShellTuiActivator.java:172)

at java.lang.Thread.run(Thread.java:534)

Caused by: java.lang.ClassNotFoundException: com.sap.engine.services.jndi.Initia

lContextFactoryImpl

at java.net.URLClassLoader$1.run(URLClassLoader.java:199)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:187)

at java.lang.ClassLoader.loadClass(ClassLoader.java:289)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)

at java.lang.ClassLoader.loadClass(ClassLoader.java:235)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:219)

at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav

a:42)

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6

49)

... 11 more

I have started a bundle sapj2eeclient which exports the package com.sap.engine.services.jndi AND have included the jar-file with the bundle by

specifying

Bundle-ClassPath: ., lib/bundle/sapj2eeclient.jar

in the the devhl.jar bundle's manifest.

Do you have an idea what is going wrong here?

Thanks for your help, again!

PS:

Also, just to make sure I'm not working in a wrong direction: Is it generally possible to use JMS inside an OSGI bundle? (What I actually want to look up here is a QueueFactory, not a bean).

Former Member
0 Kudos

Hi Katrin,

It is possible to have a remote client that uses JMS launched by a standard java program (with a main class). However I am not familiar with OSGI.

Looking at the exception

com.sap.engine.services.jndi.InitialContextFactoryImpl

is not in the classpath. Probably it's not included properly in the bundle.

Btw, besides jndi, you will need to export you your bundle everything under

com.sap.jms from the sapj2eeclient.jar. You will reach to that problem when attempting to perform a lookup for the JMS connection factory.

HTH

Peter