I have tried adding connection pooling for a MySQL database in Tomcat 5.5 by following the steps described here. Now when I start Tomcat my application fails to load. The only message I can find in any of the logs is
Where can I look for further information on what is causing the error? I'm pretty sure that I have followed the Tomcat Connection Pooling example faithfully (I added the commons libraries to Tomcat's lib directory, I modified my server.xml and web.xml as shown, etc.), and the XML I added to the server.xml appears to be valid. In any event I will include the XML which I added to Tomcat's server.xml just in case anyone can see a mistake (the following is included under the <Host> element which defines localhost):
Please note that for tomcat 5.x, unlike tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. Instead, put them in the META-INF/context.xml directory of your WAR file or the conf directory as described above.
I personally, place my Context.xml configurations in my META-INF directory of my web application and I have had no problems. I try to not touch the Server.xml unless I have to.
So, I hope the information above may shed some light on your situation.
Joined: Sep 12, 2003
Thanks for the insight.
I have now created a context.xml according to the example in the Tomcat 5.5 documentation (the example I was following before was from the Tomcat 5.0 documentation, which I've since been told is not applicable to version 5.5) and this time I've placed it my application's META-INF directory in the WAR. Unfortunately I still get the same errors as before, with no more information in the log files other than the cryptic "SEVERE: Error listenerStart" message.
Below are the contents of my META-INF/context.xml file. Does anything look amiss now? Perhaps I need to enclose this <Context> entry with a <Server>, <Service>, or <Host> entry?
It turns out that the above works fine, except that I needed to remove the path attribute from the Context, which isn't necessary or recommended when configuring the Context outside of the server.xml file.
Finally it looks as if this is not a Tomcat problem but a problem with my application, which is using Spring and Hibernate. If I don't try to access this MySQL DBCP DataSource via JNDI then my application will start fine, but once I try to configure the DataSource in Spring by using a JndiObjectFactoryBean then the troubles begin. Hopefully I can work this out...
Joined: Sep 12, 2003
I finally worked this out. Here are the steps involved:
1. In the WAR file for the web application create a META-INF/context.xml file. In this file create the DataSource resource which will eventually be accessed via JNDI by Spring:
2. In the WEB-INF/web.xml of the web application's WAR file add a resource reference:
3. In the Spring configuration create a JndiObjectFactoryBean which can be used as a factory for a DataSource:
4. Use this JndiObjectFactoryBean as a DataSource bean for the session factory bean used by DAOs:
I hope this will be helpful.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Tomcat application won't start with MySQL Connection Pooling