问题
I've been trying to get a c3p0 db connection pool configured for Jetty, but I keep getting a ClassNotFoundException:
2010-03-14 19:32:12.028:WARN::Failed startup of context WebAppContext@fccada@fccada/phpMyAdmin,file:/usr/local/jetty/webapps/phpMyAdmin/,file:/usr/local/jetty/webapps/phpMyAdmin/
java.lang.ClassNotFoundException: org.mortbay.jetty.webapp.WebAppContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:313)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:266)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:90)
at org.eclipse.jetty.xml.XmlConfiguration.nodeClass(XmlConfiguration.java:224)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:187)
at org.eclipse.jetty.webapp.JettyWebXmlConfiguration.configure(JettyWebXmlConfiguration.java:77)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:975)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:349)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:162)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
at org.eclipse.jetty.server.Server.doStart(Server.java:228)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:990)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:955)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:394)
at org.eclipse.jetty.start.Main.start(Main.java:546)
at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:208)
at org.eclipse.jetty.start.Main.main(Main.java:75)
I'm new to Jetty and I want to ultimately get phpMyAdmin and WordPress to run on it through Quercus and a JDBC connection. Here are my web.xml and jetty-web.xml files in my WEB-INF directory.
jetty-web.xml:
jdbc/mysql
jdbc:mysql://localhost:3306/mysql
user
pw
web.xml:
Caucho Technology's PHP Implementation
My DataSource Reference
jdbc/mysql
javax.sql.DataSource
Container
Quercus Servlet
com.caucho.quercus.servlet.QuercusServlet
script-encoding
UTF-8
database
jdbc/mysql
ini-file
WEB-INF/php.ini
Quercus Servlet
*.php
index.php
I'm guessing that I'm missing a few jars or something. Currently I have placed the following jars in my WEB-INF/lib directory:
c3p0-0.9.1.2.jar
commons-dbcp-1.4.jar
commons-pool-1.5.4.jar
mysql-connector-java-5.1.12-bin.jar
I have also tried to put these jars in JETTY-HOME/lib/ext, but to no avail... Someone please tell me what is wrong with my configuration. I'm sick of digging through Jetty's crappy documentation.
回答1:
Starting with Jetty 7, Jetty has become a project of Eclipse Foundation. During the migration of Jetty 6 to Eclipse Jetty 7, a new package structure has been adopted (see the Jetty 7 Refactoring page):
Classes from org.mortbay.jetty.webapp are now in org.eclipse.jetty.webapp
Classes from org.mortbay.jetty.plus.naming are now in org.eclipse.jetty.plus.jndi
So try with the following jetty-web.xml (not tested):
jdbc/mysql
jdbc:mysql://localhost:3306/mysql
user
pw
But if you don't need fancy things from Jetty 7, my suggestion would be to stick with Jetty 6 (more stable, more documentation, more resources on Internet, less complicated, etc, in other words, less pain).
回答2:
I got the configuration to work now. I'm posting the corrected jetty-web.xml for Jetty 7.
jdbc/mysql
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/mysql
user
pw
With the following jars in WEB-INF/lib
c3p0-0.9.1.2.jar
commons-dbcp-1.4.jar
commons-pool-1.5.4.jar
mysql-connector-java-5.1.12-bin.jar
回答3:
check to make sure the OLD jetty-env.xml is not in your classpath -
In jetty 6 the jetty-env.xml begins with this:
来源:https://stackoverflow.com/questions/2451572/jetty-7-mysql-config-java-lang-classnotfoundexception-org-mortbay-jetty-weba