Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat can't find a JDBC JNDI resource

 
Aodhan Hoffman
Ranch Hand
Posts: 35
Java MyEclipse IDE Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Craig Jackson
Ranch Hand
Posts: 405
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
Java MyEclipse IDE Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
Java MyEclipse IDE Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic