DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=33360>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=33360 Summary: Cannot use JNDI datasources in ROOT context Product: Tomcat 5 Version: 5.5.7 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Catalina AssignedTo: tomcat-dev@jakarta.apache.org ReportedBy: [EMAIL PROTECTED] There appears to be an issue when attempting to use a JNDI datasource when defining a ROOT context. So with the simple server.xml: <Server port="8005" shutdown="SHUTDOWN"> <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"> <!-- HTTP connector --> <Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml" /> <!-- HTTPS connector --> <Connector port="8443" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> <!-- AJP 1.3 connector (needed?) --> <Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /> <Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name='localhost' appBase='webapps' unpackWARs='false' autoDeploy='true' deployOnStartup='true' xmlValidation='false' xmlNamespaceAware='false'> <Context path='/' docBase='ROOT.war' crossContext='true'> <Resource name='jdbc/myDB' auth='Container' type='javax.sql.DataSource' driverClassName='org.postgresql.Driver' url='jdbc:postgresql://localhost:5432/myDB' username='db-user' password='db-passwd' /> </Context> </Host> </Engine> </Service> </Server> When you do: Context ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/myDB"); Connection conn = ds.getConnection(); The following error gets throw: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) If you move the resource definition to <GlobalNamingResources> and do a resource link you get the same error. But if you change any of the following, it works fine: - Move the resource definition (or link if defined globally) to $CATALINA_HOME/conf/context.xml and remove it from the context entry in server.xml - Move the context defintion out of server.xml completely to $CATALINA_HOME/conf/Catalina/localhost/ROOT.xml - Move the context defintion out of server.xml completely to <webapp>/META-INF/context.xml - Keep the context entry and resource definition in server.xml but change the context path to something besides '/' This indicates that web applications mounted on the root context are treated differently from other web applications. I think it should be consistent. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]