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:
I am seeing the following exception in server logs:
Please advise on the possible solution for the issue.
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)
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.
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