I'm trying to configure my Spring MVC application to use connection pooling with a MySQL database. I have configured the DataSource in Tomcat 5.5.9 via a Context/Resource configuration which is included in my WAR as META-INF/context.xml. The file looks like this:
If I only have this piece of the puzzle in place then my application starts up fine when I start Tomcat. However if I actually try to use this as my DataSource (instead of the DriverManagerDataSource I use for testing) then I get an error and the application fails to start. The only error message I get in the Tomcat log file is the cryptic "Error listenerStart":
I have added the MySQL DataSource as a resource in my web.xml, like so:
I am configuring the dataSource in my Spring configuration file like so:
The MySQL DBCP DataSource can be accessed from a JSP using <sql:query var="rs" dataSource="jdbc/MySqlDataSource">, so I'm pretty sure that it's configured correctly in Tomcat and the problem is with Spring not being able to wire it correctly using JNDI.
I'm following the example from p. 256 of Harrop's "Pro Spring". I'm running Tomcat 5.5.9 on a Windows XP machine, and using Spring 1.2.3.
Thanks in advance for any assistance!
--James
Code:
<Context> <Resource name="jdbc/MySqlDataSource" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="user" password="mypassword" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/ioifocus" removeAbandoned="true" /> </Context>
Code:
Aug 8, 2005 9:54:18 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive ioifocus.war Aug 8, 2005 9:54:20 AM org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart Aug 8, 2005 9:54:20 AM org.apache.catalina.core.StandardContext start SEVERE: Context [/ioifocus] startup failed due to previous errors
Code:
<!-- JNDI Reference to the MySQL DataSource --> <resource-ref> <description>MySQL Database Connection</description> <res-ref-name>jdbc/MySqlDataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
Code:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:comp/env/jdbc/MySqlDataSource</value> </property> </bean>
I'm following the example from p. 256 of Harrop's "Pro Spring". I'm running Tomcat 5.5.9 on a Windows XP machine, and using Spring 1.2.3.
Thanks in advance for any assistance!
--James
Comment