-
-
2. Re: EJB lookup
mohanpotturi Dec 6, 2011 1:15 PM (in response to jaikiran)Hi Jaikiran,
Thanks for the prompt reply. I tried it and it did not work for me. However, I am able to look it up via context. Here is the scenario:
My application is EAR based. I have an ejb jar, a web war plus a bunch of libraries. I am trying to lookup the ejb that resides in ejb jar
from a class in web war. I have set the dependency (of ejb jar) in the manifest of war. I am not sure about the syntax though.
Name of the EAR is infolinkApp.ear
Name of the JAR is infolink-ejb.jar
Name of the WAR is infolink-web.war
Manifest entry in war file is deployment.infolinkApp.ear.infolink-ejb.jar
The EJB in question: PlaceQueryRemote (interface) and PlaceQueryRemoteBean (implementation)
This is how I am trying to reference it:
@EJB(lookup = "java:app/infolink-ejb/PlaceQueryRemoteBean") PlaceQueryRemoteBean pqr;
I tried @EJB(lookup = "java:global/infolinkApp/infolink-ejb/PlaceQueryRemoteBean") PlaceQueryRemoteBean pqr;
as well. In both the cases I get a NULL for pqr.
Thanks in advance for your inputs.
-
3. Re: EJB lookup
robertobeeman Dec 6, 2011 3:02 PM (in response to mohanpotturi)Hi Mohan,
Jaikiran will be able to explain you better... I am just trying to add some of my findings.
The syntax for the EJB Global JNDI is as following:
java:global[/<app-name>l]/<module-name>/<bean-name>l[!<fully-qualified-interface-name>l]
For App Scope it is as following:
java:app/<module-name>l/<bean-name>l[!<fully-qualified-interface-name>l]
So your jndi name does not look good it has missing ' ! ' (missing exclaimation mark)
Also please refer to the following link: http://middlewaremagic.com/jboss/?p=822
Also as soon as you deploy your EJBs successfully on JBoss AS you will be able to see their actual JNDI names in the JBoss Console output (STDOUT) something as following:
java:global/TestLocalEJBEAR/localEJB/CallerName!caller.CallerLocal
java:app/localEJB/CallerName!caller.CallerLocal
java:module/CallerName!caller.CallerLocal
java:global/TestLocalEJBEAR/localEJB/CallerName
java:app/localEJB/CallerName
java:module/CallerName
-
4. Re: EJB lookup
mohanpotturi Dec 6, 2011 3:09 PM (in response to robertobeeman)Thaks Roberto. Let me give it a spin and see what we get.
-
5. Re: EJB lookup
mohanpotturi Dec 6, 2011 3:41 PM (in response to robertobeeman)Tried with the ! plus fully qualified class name of the interface. Still no joy. Tried both global and app versions.
-
6. Re: EJB lookup
sfcoy Dec 6, 2011 5:42 PM (in response to mohanpotturi)I'm curious as to why you're using remote interfaces in a co-located ejb-jar/war situation.
-
7. Re: EJB lookup
mohanpotturi Dec 6, 2011 7:03 PM (in response to sfcoy)We have client applications that call in the EJBs across the wire. In this particular test environment that I was referring to, it is a local reference but I did not want to change the server code just for the test.
-
8. Re: EJB lookup
sfcoy Dec 6, 2011 7:20 PM (in response to mohanpotturi)1 of 1 people found this helpfulOK, in an example I posted in Two Different EARs(same JVM), looking each other ejb's throws ClassNotFoundException
this style of lookup
@EJB(lookup="java:global/ejbremote-core-ear/ejbremote-core-ejb/HelloServiceBean")
is working fine. Maybe you can find some clues there?
Note that you must use the 7.1 beta for this, as I don't think 7.0.x supports remote EJBs.
-
9. Re: EJB lookup
mohanpotturi Dec 6, 2011 7:43 PM (in response to sfcoy)I looked at the attachments you have posted Steve. The only difference I could see is that the @EJB(lookup = "xxx") annotation is placed in a servlet class in your case and it is in a POJO (inside the WAR file) in my case. Do you think that the injection of the ejb reference takes place only inside of classes that are EJBs and SERVLETs ( I mean container managed entities)? BTW, I am using 7.1.0.Beta1
-
10. Re: EJB lookup
mohanpotturi Dec 6, 2011 7:56 PM (in response to mohanpotturi)I did a simple test by placing the annotation inside a servlet class and sure enough, the injection takes place there. So the annotations work only inside of the entities managed by the container. I mean at least the @EJB annotation. If anybody has more inputs on this you are more than welcome to post them. I appreciate all the help.
-
11. Re: EJB lookup
sfcoy Dec 6, 2011 7:58 PM (in response to mohanpotturi)This will happen unless you have a META-INF/beans.xml file in your war file for CDI to work.
-
12. Re: EJB lookup
mohanpotturi Dec 7, 2011 11:46 AM (in response to sfcoy)Thank you Steve. When I added beans.xml to WEB-INF directory of my war, the deployment crapped out with errors that siad Can't find resource bundle for ch.qos.cal10n.util.<SomeClass>. I do not remember the name of the class exactly. I am away from my desk right now. I looked at the modules that are bundled with 7.1.0.Beta1 and saw ch.qos.cal10n but there is no ch.qos.cal10n.util in there. What am I missing?
-
13. Re: EJB lookup
sfcoy Dec 7, 2011 6:53 PM (in response to mohanpotturi)At this point we need more information such as stack traces and details of your deployment