Paul Maxted wrote: > Hello, I need some help with my database access application. > > I am running Tomcat 6.0.16-6.4 installed from the OpenSUSE repositories. I am > trying to connect to MySQL 5.0.51a-27.2. > I have mysql-connector-java-5.1.7-bin.jar in the tomcat6/lib directory. > > I have not modified server.xml or context.xml in tomcat6/conf - I include > them for reference > > server.xml > <code> > <?xml version='1.0' encoding='utf-8'?> > .... snipped .... as a side note it would help all of us (you included) if you create a copy of the server.xml file without all the comments and use that in production instead. Keep the original around for reference, but definitely create a copy for production without all the comments. Otherwise, there's nothing in server.xml impacting your problem.
> </code> > > context.xml > <code> > <?xml version='1.0' encoding='utf-8'?> > ... snipped ... the global context.xml file shouldn't be changed anyway unless you're making changes you want to affect the behavior of all webapps. > </code> > > My application 'AuthExample' is deployed as a war file which expands to ... > <code> > > ... snipped ... looks normal enough > </code> > > META-INF/context.xml > <code> > <?xml version="1.0" encoding="UTF-8"?> > > <Context path="/AuthExample"> > > <Resource name="jdbc/AuthExample" > auth="Container" > type="javax.sql.DataSource" > driverClassName="com.mysql.jdbc.Driver" > url='jdbc:mysql://localhost:3306/javaexamples?validationQuery="select > 1"' > username="Validate" > password="Authenticate"/> > > </Context> > </code> > > Ok ... I would recommend a couple of changes here. 1. Your url attribute should be url="jdbc:mysql://localhost:3306/javaexamples" (notice I dropped the validationQuery= ... stuff. 2. Insert a attribute validationQuery="select 1" in the <Resource ... /> element. This is how validation queries are supposed to be put in. > WEB-INF/web.xml > <code> > <?xml version="1.0" encoding="ISO-8859-1"?> > > <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"> > > <display-name>Authentication Example</display-name> > <description> > This is an examlpe servlet for User Authentication. > </description> > > <servlet> > <servlet-name>AuthExample</servlet-name> > <servlet-class>com.xxxx.AuthExample</servlet-class> > </servlet> > > <servlet-mapping> > <servlet-name>AuthExample</servlet-name> > <url-pattern>/authenticate</url-pattern> > </servlet-mapping> > > <resource-ref> > <description>jdbc/AuthExample</description> > <res-ref-name>jdbc/AuthExample</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > > </web-app> > </code> > > Again .. normal enough. You didn't do anything weird to the case of jdbc/AuthExamples which a lot of people do. Things are spelled correctly. > Login,java > <code> > > > > public class Login { > > > DataSource ds = null; > > try { > > Context ctx = new InitialContext(); > > ds = > (DataSource)ctx.lookup("java:comp/env/jdbc/AuthExample"); > > } catch (NamingException e1) { > > System.out.println("Login:authenticate:Context > Setup"); > > e1.printStackTrace(); > > } > > > } > Forgive my cutting down your code a little. The important parts look correct. > </code> > > Full Stack Trace > <code> > INFO: Undeploying context [/AuthExample] > 03-Mar-2009 13:24:12 org.apache.catalina.startup.HostConfig deployWAR > INFO: Deploying web application archive AuthExample.war > Login:authenticate: > 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:1150) > at > org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) > at com.aricent.Login.authenticate(Login.java:29) > at org.apache.jsp.process2_jsp._jspService(process2_jsp.java:71) > at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > at > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) > at > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) > at > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) > at java.lang.Thread.run(Thread.java:619) > Caused by: java.lang.NullPointerException > at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507) > at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476) > at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307) > at java.sql.DriverManager.getDriver(DriverManager.java:253) > at > org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143) > ... 21 more > </code> > > I have deployed this without issue on a Windows XP laptop and read endless > mailing lists .... > > ThanKs, > Paul > > Your error typically comes from some sort of mismatch in your setup like mismatched case on jdbc names. I'm not seeing that, so try fixing what I pointed out in your META-INF/context.xml file and see if that changes anything. --David --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org