permaculture playing cards*
The moose likes Tomcat and the fly likes 'jdbc' in JNDI name causes problem on Tomcat 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark " Watch " New topic
Author

'jdbc' in JNDI name causes problem on Tomcat 6

Mark Regan
Greenhorn

Joined: Aug 18, 2006
Posts: 9
Hi,

I don't have a great deal of experience using Tomcat, but have come across a weird problem that I can't solve.

I'm using Tomcat 6.0.26 with eclipse Galileo JEE edition.

I've configured a Datasource according to the Tomcat docs, as follows:

under the Servers folder created in eclipse, in the context.xml file I have added:


and in the web.xml of the web project I have added:


I look up the datasource from a servlet as follows:


The DB driver jar files have been placed under WEB-INF/lib.

When running this I get the (root) exception of


However, if I remove the jdbc/ from all of the occurrences of the JNDI name shown above, the lookup and the subsequent connections to the DB work fine!

i.e.





I don't really want to the leave the servlet code this way, since it can be used on other app servers as well (it's used for demo's), where 'jdbc/db2conn' works no problem.

I've google'd for hours and can't find a mention of this anywhere.

Anyone have any ideas?

Thanks

Mark.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

I don't see any problem myself. I've used the "jdbc" convention for years now, including in a number of projects running under Tomcat6. In fact, I converted one just last week.

So whatever it is, it's probably not Tomcat6.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mark Regan
Greenhorn

Joined: Aug 18, 2006
Posts: 9
Thanks Tim,

Yes I'm starting to wonder if it has something to do with Eclipse and the way it deploys the app?

Still can't understand that it won't work with jdbc/ but will work without it.

I've been looking at this other thread here http://www.coderanch.com/t/490267/Tomcat/connection-DataSource-object#2205754 and following some of your's and other peoples suggestions. One of the things is that the context.xml under META-INF should contain the Resource def, however this file does not seem to be copied into the deployment location anywhere that I can find.

Anyone else have experience of using Tomcat6 with eclipse 3.5?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

Mark Regan wrote:Thanks Tim,

Yes I'm starting to wonder if it has something to do with Eclipse and the way it deploys the app?

Still can't understand that it won't work with jdbc/ but will work without it.

I've been looking at this other thread here http://www.coderanch.com/t/490267/Tomcat/connection-DataSource-object#2205754 and following some of your's and other peoples suggestions. One of the things is that the context.xml under META-INF should contain the Resource def, however this file does not seem to be copied into the deployment location anywhere that I can find.

Anyone else have experience of using Tomcat6 with eclipse 3.5?


Oh. that %$#%$#!!! Eclipse WTP Server thing again.

I hate the WTP server plugin. It selectively copies parts of your tomcat conf directory into a private location, then mucks around with the copies. I have been so frustrated with it that I've been launching an external Tomcat and using remote debugging on it instead. I much prefer the sysdeo plugin. It was much more well-behaved with Tomcat. Unfortunately, it didn't work with Ganymede, so I switched to WTP and almos immediately regretted it. I've seen hints that maybe sysdeo has been updated since then. I was afraid it was no longer being supported.

Most likely your config changes are not being propagated into WTP's copy of the conf files. You sometimes have to manually force them. So, in other words, you think you're running under a "jdbc/dsn" naming scheme, but actually it's still stuck using the "dsn" naming schem.
Mark Regan
Greenhorn

Joined: Aug 18, 2006
Posts: 9
Got it working Tim.

After you lastest comments, I found the docs for the WTP Tomcat adaptor.

The default behaviour of the Server Configuration is that ignores the META-INF/context.xml file.

The setting 'Publish module contexts to separate xml files' is the one that enables this.

And hey presto, it's working with jdbc/ now.

FWIW I remember using the sysdeo plugin years ago myself and had forgotten about it. It looks as though it does support 3.5 now.

Thanks very much for you your time and inspiration, Tim.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 'jdbc' in JNDI name causes problem on Tomcat 6
 
Similar Threads
JBOSS connection pooling
Unable make database connection using JNDI with tomcat
JNDI on startup
Could not perform loook up operation in JBoss..need urgent help
DataSource is Null in JNDI Connection with Tomcat