aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Remote Java EE Client with JNDI Lookup for Remote Session Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Remote Java EE Client with JNDI Lookup for Remote Session Beans" Watch "Remote Java EE Client with JNDI Lookup for Remote Session Beans" New topic
Author

Remote Java EE Client with JNDI Lookup for Remote Session Beans

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Source:OCP JavaEE 6 EJB Developer Study Notes by Ivan A Krizsan


I was trying to get reference to EJB(StatefulSession1Bean) using JNDI lookup for Remote-Client for same example as mentioned in 5.2.2. Remote Java EE Client with Dependency Injection with the below changes:

RemoteEJBClientServlet



I am seeing the following exception in server logs:



Please advise on the possible solution for the issue.


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

Hi Mohit,

Did you check the console log when starting up your application? You will find the global JNDI names being logged.

There is one small mistake though in your setup: In the PostConstruct method you only have JNDI access to "java:comp/env" (check chapter 4.6.1 table 1)

Regards,
Frits
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Did you check the console log when starting up your application? You will find the global JNDI names being logged.


These were the JNDI names seen at startup of application:


There is one small mistake though in your setup: In the PostConstruct method you only have JNDI access to "java:comp/env" (check chapter 4.6.1 table 1)


I couldn't find any table under section:chapter 4.6.1 table 1(OCP JavaEE 6 EJB Developer Study Notes by Ivan A Krizsan,Version: April 8, 2012)
Also,I see that java:global,java:app,java:module can be used under PostConstruct method as mentioned under example (5.1.3. Local Session Bean Client with JNDI Lookup)
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

I couldn't find any table under section:chapter 4.6.1 table 1(

Sorry, I meant the ejb-specs chapter 4.6.1 table 1, but I now see that the PostConstruct is inside a Servlet (and not an EJB) so never mind this table as it is not relevant anymore...

Hmmmm... you are getting a NameNotFoundException, although it looks like you are using the correct name (btw I don't see the definition of your EJB)
Is the EJB packaged in the war or is it packaged in a separate jar?
Have you tried doing the lookup from the doGet() ? It looks like the global name is not yet available in the server.

Regards,
Frits
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Hi Frits,

The Programs works fine now.
I was removing the RemoteSessionBean project from Add and Remove(Run on a Server) window on starting the RemoteEJBClientServlet on GlassFish Server.
The problem is resolved now
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

aha, ok, that was the problem!

Regards,
Frits
 
Consider Paul's rocket mass heater.
 
subject: Remote Java EE Client with JNDI Lookup for Remote Session Beans