on 04-28-2005 1:33 PM
Hi,
I am working on SAP Netweaver. We have created a stateless session bean which is finally deployed as a webservice. From this stateless session bean we need to call another stateless session bean as a local reference.
I have done the following.
1. Added JNDI-Name to the ejb-j2ee-engine.xml.
2. My lookup code is as follows
Context context = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
context = new InitialContext(env);
Object ejbObj = context.lookup("MyBean");
But i get the NamingException .Here MyBean is the jndi-name provided in the ejb-j2ee-engine.xml.
Can somebody tell me what i am doing wrong.
Thanks
Priya
Hi,
I tried changing the lookup string to java.comp/ .But i get this error message " Naming Exception : Path to object does not exist at java:comp".I have removed the jndi-name from the ejb-j2ee-engine.xml also.
In the previous code the PathfromJNDIRegistry actually meant the context from JNDI Registry from visual admin. I can see my bean there and i tried lookup using information from JNDIRegistry.When i do that i get RemoteException (Error while loading the class).
Regards
Priya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Priya,
in my opinion you find referenced beans into the underlying context of the bean in which you had the reference. Have a look in your Visual Administrator -> Cluster Tab -> Services -> JNDI Registry. There you can find your deployed bean and it's
own
context where the Bean MyBean is.Furthermore try
context.lookup("java:comp/MyBean");
.
Regards André
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for your replies.I did as you had suggested.I added ejb-local-ref to the ejb-jar.xml and i provided ejb-ref as MyBean.
My lookup code uses the string
ctxt.lookup("localejbs\MyBean");
But still i get Naming Exception.
I tried something different yesterday.
I changed the code to use
InitialContext ctxt = new InitialContext();
ctxt.lookup("localejbs/"+ pathfromJNDIRegistry);
and this time i did not get Naming exception but i got RemoteException saying there was error loading the class.
Is there something i need to add somewhere for the classloader to be able to find and load this class in the second scenario.
Please suggest me which method to go for amongst the two and what is the missing information i need to add.
Thanks
Priya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Priya,
and a small addition from my side too: if you want to lookup the local home interface, you must declare an ejb-local-ref instead of ejb-ref.
Best regards,
Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
in addition to Andre's reply, you can have a look at this post: (it describes how to add the reference in the web.xml, but it's analogous for the ejb-jar.xml).
Also, keep in mind that in this case you should lookup the EJB relative to the java:comp/env context (you can see the correct lookup string in the above thread also.)
Hope that helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Priya,
you can create a ejb-ref in the ejb-jar.xml for the SessionBean you want to reference to. So the Context of the second SessionBean know this Bean under the given EJB Reference Bean.
Regards André
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.