简体   繁体   中英

Jetty + Derby No suitable driver found

I am working with Jetty + Derby in Eclipse. I got this error:

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/airlinesDB;user=slc;password=slc;"
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:314)
at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:197)
at org.apache.jsp.Welcome_jsp._jspx_meth_sql_query_0(Welcome_jsp.java:433)
at org.apache.jsp.Welcome_jsp._jspService(Welcome_jsp.java:108)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:558)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:489)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:972)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:906)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:267)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:98)
at com.ibm.sample.LoginServlet.doPost(LoginServlet.java:61)

Looking at LoginServlet.java code, in line 61, it's:

getServletContext().getRequestDispatcher("/Welcome.jsp").forward(request, response);

Since I moved the whole project from Tomcat Server to Jetty Server, and the project can run successfully in Tomcat configuration. Thus I am sure the URL in web.xml is correct. I think the question is probably due to some incorrect configuration in Jetty.

I also exported the full project in WAR format, you can access it via:

https://drive.google.com/file/d/0B1EhxQ7GBJdsYUlzZ1UtTkIxQTg/edit?usp=sharing

To run this project( or you just want to view the source files), you can import this project in Eclipse. The java source files are under com.ibm.sample package. Also for software Prerequisites to run the project,you should install Derby and Jetty plugins in Eclipse.

To run it, you can first start Derby Network Server, then launch Jetty, and then open this url:

localhost:8080/Test/Welcome.jsp

Then type slc/slc as username and password to login.

Above is all steps you need to do if you want to run it.

Thanks very much for your suggestions or help!!

That url requires client driver found in derbyclient.jar Check that you can access the exact same url in ij, with derbyclient.jar on the classpath. If you can, it means that the Derby client driver recognizes the url. Then the only other explanation is that your jetty server does not have derbyclient.jar on the classpath when trying to get the connection.

Since I don't know how to configure jetty, I don't know where the error could be. But I would look for any place where jars are listed and make sure derbyclient.jar is included.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM