Re: 6.0.13 MySQL DBCP Example
To make use a GlobalNamingResources .. /GlobalNamingResources, you'll have to put a ResourceLink element in your webapp's context.xml file. See the end of http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html for more information. --David G M wrote: Thanks! It worked when I put the Context.../ in the context.xml of my webapp META-INF directory. However when I tried to put it in the global context.xml it doesn't work. Tomcat should put this information in his example. Why it doesn't work in the global context.xml, any ideas? Here is the context if you need to check it out. ?xml version=1.0 encoding=UTF-8? !-- The contents of this file will be loaded for each web application -- Context path=/DBTest docBase=DBTest debug=5 reloadable=true crossContext=true Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=gabo password=huevos driverClassName= com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ /Context Thank you a lot, is great to have my app up and running! Gabriel Moreno 2007/8/9, Caldarale, Charles R [EMAIL PROTECTED]: From: David Smith [mailto:[EMAIL PROTECTED] Subject: Re: 6.0.13 MySQL DBCP Example 1. I would merge the Context / element from server.xml to your context.xml file and remove the Context element from your server.xml. Just a point of clarification: the context.xml above refers to the one in your webapp's META-INF directory, not the global one in Tomcat's conf directory. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 6.0.13 MySQL DBCP Example
Ok... tomcat 6.0.13 1. I would merge the Context / element from server.xml to your context.xml file and remove the Context element from your server.xml. Placing this element in server.xml is not recommended anymore as it means a restart of tomcat to deploy/undeploy webapps. Also having the Context definition in two places for one webapp will undoubtedly cause problems with one overriding the other. 2. Trim any spaces in the element attributes. I saw an extraneous space in the driverClassName attribute below. 3. It's not recommended you add autoReconnect=true to the mysql db url. It has it's uses, but not in a database pool. Instead, use a validationQuery attribute in your Resource element to test and validate connections before your app borrows them. 4. I'm assuming the mysql-connector-java-*.jar file is stored in the $CATALINA_HOME/lib folder and not present in your webapp's WEB-INF/lib folder. Let us know what happens. If it still doesn't work, let us see the new context.xml file and be sure there isn't a Context ... element in the server.xml. --David G M wrote: I've been trying for days now to establish a jdbc resource for mysql in tomcat 6.0.13 To whom it may correspond: I get the following error Unable to get connection, DataSource invalid: org.apache.tomcat.dbcp.dbcp.SQLNestedException : Cannot create JDBC driver of class '' for connect URL 'null' I have the driver mysql-connector-java-5.0.6-bin.jar copied to $CATALINA_HOME/lib My application web.xml looks like this: (exactly as the example) web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd version=2.4 descriptionMySQL Test App/description resource-ref descriptionDB Connection/description res-ref-namejdbc/TestDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app In http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.htmlthere is this instruction: Add this in between the /Context tag of the examples context and the /Host tag closing the localhost definition. If there is no such tag, you can add one as illustrated in the Contexthttp://tomcat.apache.org/tomcat-6.0-doc/config/context.htmland Host http://tomcat.apache.org/tomcat-6.0-doc/config/host.htmlconfiguration references, and repeated below for your convenience. In my own opinion this is quite ambiguous. After several search in the mail repositories. I have this as my server.xml configuration (i deleted the comments for easy reading) Server port=8005 shutdown=SHUTDOWN Listener className=org.apache.catalina.core.AprLifecycleListener SSLEngine=on / Listener className=org.apache.catalina.core.JasperListener / Listener className=org.apache.catalina.mbeans.ServerLifecycleListener / Listener className= org.apache.catalina.mbeans.GlobalResourcesLifecycleListener / GlobalNamingResources Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / /GlobalNamingResources Service name=Catalina Connector port=8080 protocol=HTTP/1.1 connectionTimeout=2 redirectPort=8443 / Connector port=8009 protocol=AJP/1.3 redirectPort=8443 / Engine name=Catalina defaultHost=localhost Realm className=org.apache.catalina.realm.UserDatabaseRealm resourceName=UserDatabase/ Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Context path=/DBTest docBase=DBTest debug=5 reloadable=true crossContext=true Resource name=jdbc/TestDB auth=Container type= javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=gabo password=huevos driverClassName= com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ /Context /Host /Engine /Service /Server In my own opinion the problem is with server.xml, should I add something to context.xml? Any comment, hint or tip would be greatly appreciated. Regards Gabriel - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: 6.0.13 MySQL DBCP Example
From: David Smith [mailto:[EMAIL PROTECTED] Subject: Re: 6.0.13 MySQL DBCP Example 1. I would merge the Context / element from server.xml to your context.xml file and remove the Context element from your server.xml. Just a point of clarification: the context.xml above refers to the one in your webapp's META-INF directory, not the global one in Tomcat's conf directory. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
6.0.13 MySQL DBCP Example
I've been trying for days now to establish a jdbc resource for mysql in tomcat 6.0.13 To whom it may correspond: I get the following error Unable to get connection, DataSource invalid: org.apache.tomcat.dbcp.dbcp.SQLNestedException : Cannot create JDBC driver of class '' for connect URL 'null' I have the driver mysql-connector-java-5.0.6-bin.jar copied to $CATALINA_HOME/lib My application web.xml looks like this: (exactly as the example) web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd version=2.4 descriptionMySQL Test App/description resource-ref descriptionDB Connection/description res-ref-namejdbc/TestDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app In http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.htmlthere is this instruction: Add this in between the /Context tag of the examples context and the /Host tag closing the localhost definition. If there is no such tag, you can add one as illustrated in the Contexthttp://tomcat.apache.org/tomcat-6.0-doc/config/context.htmland Host http://tomcat.apache.org/tomcat-6.0-doc/config/host.htmlconfiguration references, and repeated below for your convenience. In my own opinion this is quite ambiguous. After several search in the mail repositories. I have this as my server.xml configuration (i deleted the comments for easy reading) Server port=8005 shutdown=SHUTDOWN Listener className=org.apache.catalina.core.AprLifecycleListener SSLEngine=on / Listener className=org.apache.catalina.core.JasperListener / Listener className=org.apache.catalina.mbeans.ServerLifecycleListener / Listener className= org.apache.catalina.mbeans.GlobalResourcesLifecycleListener / GlobalNamingResources Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / /GlobalNamingResources Service name=Catalina Connector port=8080 protocol=HTTP/1.1 connectionTimeout=2 redirectPort=8443 / Connector port=8009 protocol=AJP/1.3 redirectPort=8443 / Engine name=Catalina defaultHost=localhost Realm className=org.apache.catalina.realm.UserDatabaseRealm resourceName=UserDatabase/ Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Context path=/DBTest docBase=DBTest debug=5 reloadable=true crossContext=true Resource name=jdbc/TestDB auth=Container type= javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=gabo password=huevos driverClassName= com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ /Context /Host /Engine /Service /Server In my own opinion the problem is with server.xml, should I add something to context.xml? Any comment, hint or tip would be greatly appreciated. Regards Gabriel