• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNDI connection problem

 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have an ear in which there is a war and an ejb jar. In my ejb jar under META-INF there is glassfish-resources.xml. I created a jdbc-connection-pool whose name is java:app/mydb_pool. Then I created a resource which refers to this pool whose jndi name is "java:app/mydb".

In my ejb I created an InitialContext which lookups the jndi. I am getting error. Can anyone please explain me what is wrong. Here is the code and configuration.


Thank you all in advance.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The IntialContext lookup the JNDI name not the pool name. You probably typed wrong in the XML.

 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops!! My bad, corrected it. Its just a typing mistake. But my code is right. I get the error
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Previously I was using glassfish 3.0, then I tried to deploy it on 3.1.2. Then I got this error while deployingThen I changed the scope to java:module. Even then I am not able to lookup the jndi name from my EJB.

Any ideas?
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried checking whether the resources are being created are not. So I removed the lookup code from my EJB's constructor and then redeployed the application and listsed the resources using

asadmin --host localhost --user admin --port 20048 list-applications --subcomponents --resources

I was able to see the resources. Somehow the jndi lookup is not working.

Can anyone please tell me what am I missing.

Thank you all in advance.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Holy shit!! Its working if I use @Resources annotation. But with InitialContext its not working.

Any ideas?
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry!! I just came to know that only in post construct I can do that. The issue is resolved now
reply
    Bookmark Topic Watch Topic
  • New Topic