I am working on a web application. I have placed it in webapps folder and the context file (application.xml) at Tomcat 7.0\conf\Catalina\localhost. I have configured the database connection in context file (application.xml). My Context file is as follows
You can make your XML and java code easier to read if you use the "Code" button on our message editor to wrap the examples with code tags.
I'm not too sure about your "<Logging>" element in the Context. Logging has traditionally been setup inside the webapp.
Tomcat7 changes the Connection pool infrastructure, so it's a good idea to RTFM. However, your examples seem to be defining the datasource under the JDNI name "jdbc/APPLICATIONDataSource" but looking for "DataSourceName".
That wouldn't work even in Tomcat 4, though.
An IDE is no substitute for an Intelligent Developer.
Joined: May 02, 2011
Thanks Tim for your reply.
Please let me know the meaning of RTFM.
I have configured this mapping in web.xml file and it is working fine in tomcat 4. I am facing problem in Tomcat 7.
Code in web.xml is like this :
my application is not able to read the context file thats why I am not able to connect to the database as I am getting the message : "Database connection was refused". That I have printed from my java class mentioned in my first mail.
I feel it is the issue of the location and naming convention of context file .
RTFM is geek slang for Read The Freakin' Manual. Or something like that.
As I said, you sample code and Context don't match and therefore I wouldn't expect them to work under any version of Tomcat. Hopefully the actual files do match.
Your application does not "read the context file". The Context file is technically-known as the "server-specific deployment descriptor". It, along with the "server-independent deployment descriptor" (WEB-INF/web.xml) are read and processed by the web application server (Tomcat), not by the web application itself.
Instead of printing out your own error message when an exception is received, use "e.printStackTrace()" to get the real reason behind the problem.
Joined: May 02, 2011
Let me put full details of my problem:
I am not able to connect with my database by using jndi in tomcat 7 and I am not able to get where am I wrong in my configuration. The applications with these details are working fine in tomcat 4 but it is giving problem in tomcat 7 for database connection. I have placed the web application at webapps folder and the context file at -- application/WebContent/META-INF/context.xml
Oh, I hate that message! I'm getting it myself right now. It's murder to figure out what's wrong. In my case, doubly so, since there seems to be a phantom connection unrelated to the one I'm actually using.
Your resource has parameters but no definition. So I think something very important is missing. I also notice that although you are supplying an Oracle JDBC URL, the stack track says it's trying to work with the jdbc-odbc bridge driver, not the Oracle driver.
Go to http://tomcat.apache.org and read the manual section on JDBC data sources. I believe that there's an actual Oracle example.