Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to get Connection through JNDI Datasource.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

here is my datasource file in JBOSS\deploy folder - (flytours-ds.xml)

####my web.xml file######

####jboss-web.xml#####


#### Java class####




When staring the server it throws this exception,


can anyone suggest me a way to get this working?
 
Shane Connors
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to remind im using JBoss4.2 in Windows XP
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that "Java class" a servlet? You can't use the java:comp/env in any Java class. It has to be an enterprise component (like servlet).
 
Shane Connors
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:Is that "Java class" a servlet? You can't use the java:comp/env in any Java class. It has to be an enterprise component (like servlet).



Hi,

Thats a normal java class, servlet calls this class to get DB connection. wht should i do here?

i have tested this with below coding too
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the entire exception stacktrace and the relevant code from your servlet which calls this class.
 
Shane Connors
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:Please post the entire exception stacktrace and the relevant code from your servlet which calls this class.



Complete stack trace is huge, i have copied some part



Servlet

PropertyLoader

 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, so you are looking it up in a ServletContextListener when the context is initialized. I'm not sure the JNDI java:comp/env is setup correctly at that time.

By the way, why do you want to hold the DB connection in the ServletContextListener?
 
Shane Connors
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:Ah, so you are looking it up in a ServletContextListener when the context is initialized. I'm not sure the JNDI java:comp/env is setup correctly at that time.

By the way, why do you want to hold the DB connection in the ServletContextListener?



Well...

its working fine with tomcat 6, i wanted to shift this to JBoss 4.2, i couldnt do that because of this issue..
 
Grow a forest with seedballs and this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic