on 03-22-2006 12:27 PM
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!
Hi Katrin,,
in your ejb-j2ee-engin.xml file ,,
change like this... and try..
In ejb-j2ee-engine.xml I have specified:
<enterprise-bean>
<ejb-name>MetaManagerBean</ejb-name>
<jndi-name><b>MetaManager</b></jndi-name>
<ejb-local-ref>
<ejb-ref-name>InfoItemLocal</ejb-ref-name>
<jndi-name><b>InfoItemLocal</b></jndi-name>
</ejb-local-ref>
<session-props/>
</enterprise-bean>
then look up the for loca home like this..
Context initial = new InitialContext();
InfoItemLocalHome home = (InfoItemLocalHome)initial.lookup("<b>localejbs/InfoItemLocal</b>");
Regards
Kishor Gopinathan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Hi Katrin,
The type of bean used in your program is called "co-located" bean. These beans are deployed in the same EJB container system and executed on the same Java VM.
To access co-located beans by using the local and local home interfaces, you need to prefix the lookup by "localejbs/".
In case of remote lookups, the prefix "localejbs/" is not needed. This is the reason for your remote lookup works fine with the original code "sap.com/ejb/InfoItemLocal".
Hope this clears your doubt.
Regards,
Uma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maksim,
Your solution worked fine, thanks alot! Still, I do not understand why mine didn't do.. 😕
Regards,
Katrin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Katrin,
try localejbs/sap.com/<NAME_OF_ENTERPRISE_APPLICATION>/InfoItemBean.
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.