aspose file tools*
The moose likes Tomcat and the fly likes Tomcat can't find a JDBC JNDI resource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat can Watch "Tomcat can New topic
Author

Tomcat can't find a JDBC JNDI resource

Aodhan Hoffman
Ranch Hand

Joined: May 21, 2004
Posts: 35

I'm trying to write a tag that takes form input and inserts it into a database. (Perhaps not clean, but I'm playing around. )

I'm using Netbeans 4.x ( which includes Tomcat 5.5.x ).

WHen I submit the form I get the following error ( truncated )



I read the JNDI HOW-TO, other Tomcat documents relating to JDBC and JNDI naming, as well as other research. The result is a slightly mixed approach that closely matches the recommendations from the HOW-TO. Comparing what I have to the HOW-TO, I don't know where the issue is.

Here's the server.xml entry:



Here's the context.xml ( within the webapp file system ) entry :


Here's the deployment descriptor for the webapp:


and finally the code that's supposed to be initializing the DataSource


The line it specifically hiccups on is this one:


Any input would be appreciated, thanks!


-------<br /> Aodhan H - Ad Astra Per Aspera<br /> -------
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
No apparent syntax errors jump out.

So I would suggest a couple things...

1. When Tomcat starts up, check the log/console to verify that your configurations did not generate any errors.

2. Where in your web application did you place the context.xml file?
Aodhan Hoffman
Ranch Hand

Joined: May 21, 2004
Posts: 35

The only start up errors I get has something to do with tomcat already using the port it wants to use. ( A perplexing error that doesn't seem to stop tomcat from launching. )

The context.xml file is in webapps/jobtracker/META-INF/context.xml.

For sanity, I quit NetBeans, went on with life for a couple of hours, read your post and tried again. THis time, it magically worked. NetBeans itself, not just Tomcat, must have needed a restart. An annoying lesson. I need to find out how to get netbeans to use MY tomcat installation...but that's a separate issue.

Regardless, I appreciate your time verifying my configuration.

Now, I am getting a 'connection pool exhausted' error on submitting the form.



The function in question is this:


The specific line is:


So I went back and confirmed the related information was specified in the server.xml file:


Now there should be more than enough connections. However, I am doing a batch. (One form entry is still only one query though. ) Could this be a problem? Is there somewhere else I should look for trouble?

THanks again.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
How are you closing your connections, thus returning the connection back to the pool?


Is your connection object stored in a instance variable? I usually try to acquire a connection, run my query(s), close connection, resultsSet(s) all withing one method call.
Aodhan Hoffman
Ranch Hand

Joined: May 21, 2004
Posts: 35

Based on your suggestion Craig I rooted around and found the problem. I was stumbling over the connection pool concerns, just trying to get them to work, I missed the more basic JDBC related errors. Your mention regarding the Connection object got me back on track.

Many thanks for your time!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat can't find a JDBC JNDI resource
 
Similar Threads
Unable make database connection using JNDI with tomcat
DataSource is Null in JNDI Connection with Tomcat
naming.NameNotFoundException
DB connection doesn't seem to work after migration from Tomcat
JNDI problem