Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Remote Java EE Client with JNDI Lookup for Remote Session Beans

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Creator of Enthuware JWS+ V6
Posts: 3348
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 3348
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3348
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aha, ok, that was the problem!

Regards,
Frits
 
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic