码头 7 + MySQL 配置 [java.lang.ClassNotFoundException: org.mortbay.jetty.webapp.WebAppContext]

发布于 2024-08-26 01:23:13 字数 6076 浏览 4 评论 0原文

我一直在尝试为 Jetty 配置 c3p0 db 连接池,但我不断收到 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)

我是 Jetty 的新手,我希望最终让 phpMyAdmin 和 WordPress 通过 Quercus 和 JDBC 连接在其上运行。这是我的 WEB-INF 目录中的 web.xml 和 jetty-web.xml 文件。

jetty-web.xml:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <New id="mysql" class="org.mortbay.jetty.plus.naming.Resource">
        <Arg>jdbc/mysql</Arg>
        <Arg>
            <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <Set name="Url">jdbc:mysql://localhost:3306/mysql</Set>
                <Set name="User">user</Set>
                <Set name="Password">pw</Set>
            </New>
        </Arg>
    </New>
</Configure>

web.xml:

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
    <description>Caucho Technology's PHP Implementation</description>
    <resource-ref>
        <description>My DataSource Reference</description>
        <res-ref-name>jdbc/mysql</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

    <servlet>
        <servlet-name>Quercus Servlet</servlet-name>
        <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>

        <!--
            Specifies the encoding Quercus should use to read in PHP scripts.
        -->
        <init-param>
            <param-name>script-encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>

        <!--
            Tells Quercus to use the following JDBC database and to ignore the
            arguments of mysql_connect().
        -->
        <init-param>
            <param-name>database</param-name>
            <param-value>jdbc/mysql</param-value>
        </init-param>

        <init-param>
            <param-name>ini-file</param-name>
            <param-value>WEB-INF/php.ini</param-value>
        </init-param>

    </servlet>

    <servlet-mapping>
        <servlet-name>Quercus Servlet</servlet-name>
        <url-pattern>*.php</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.php</welcome-file>
    </welcome-file-list>
</web-app>

我猜我丢失了一些罐子或其他东西。目前我已将以下 jar 放在 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

我也尝试将这些 jar 放在 JETTY-HOME/lib/ext 中,但无济于事...有人请告诉我我的配置有什么问题。我厌倦了挖掘 Jetty 的蹩脚文档。

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:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <New id="mysql" class="org.mortbay.jetty.plus.naming.Resource">
        <Arg>jdbc/mysql</Arg>
        <Arg>
            <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <Set name="Url">jdbc:mysql://localhost:3306/mysql</Set>
                <Set name="User">user</Set>
                <Set name="Password">pw</Set>
            </New>
        </Arg>
    </New>
</Configure>

web.xml:

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
    <description>Caucho Technology's PHP Implementation</description>
    <resource-ref>
        <description>My DataSource Reference</description>
        <res-ref-name>jdbc/mysql</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

    <servlet>
        <servlet-name>Quercus Servlet</servlet-name>
        <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>

        <!--
            Specifies the encoding Quercus should use to read in PHP scripts.
        -->
        <init-param>
            <param-name>script-encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>

        <!--
            Tells Quercus to use the following JDBC database and to ignore the
            arguments of mysql_connect().
        -->
        <init-param>
            <param-name>database</param-name>
            <param-value>jdbc/mysql</param-value>
        </init-param>

        <init-param>
            <param-name>ini-file</param-name>
            <param-value>WEB-INF/php.ini</param-value>
        </init-param>

    </servlet>

    <servlet-mapping>
        <servlet-name>Quercus Servlet</servlet-name>
        <url-pattern>*.php</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.php</welcome-file>
    </welcome-file-list>
</web-app>

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无所谓啦 2024-09-02 01:23:13

从 Jetty 7 开始,Jetty 已成为 Eclipse 基金会的一个项目。在 Jetty 6 迁移到 Eclipse Jetty 7 的过程中,采用了新的包结构(请参阅 Jetty 7 重构 页):

  • 来自 org.mortbay.jetty.webapp 的类现在位于 org.eclipse.jetty.webapp
  • 中。 mortbay.jetty.plus.naming 现在位于 org.eclipse.jetty.plus.jndi 中,

因此请尝试使用以下 jetty-web.xml (未测试):

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <New id="mysql" class="org.eclipse.jetty.plus.jndi.Resource">
        <Arg>jdbc/mysql</Arg>
        <Arg>
            <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <Set name="Url">jdbc:mysql://localhost:3306/mysql</Set>
                <Set name="User">user</Set>
                <Set name="Password">pw</Set>
            </New>
        </Arg>
    </New>
</Configure>

但如果你不需要 Jetty 7 的花哨东西,我的建议是坚持使用 Jetty 6(更稳定、更多文档、更多互联网资源、更简单等等,换句话说,更少痛苦)。

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):

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <New id="mysql" class="org.eclipse.jetty.plus.jndi.Resource">
        <Arg>jdbc/mysql</Arg>
        <Arg>
            <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <Set name="Url">jdbc:mysql://localhost:3306/mysql</Set>
                <Set name="User">user</Set>
                <Set name="Password">pw</Set>
            </New>
        </Arg>
    </New>
</Configure>

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).

梦开始←不甜 2024-09-02 01:23:13

我的配置现在可以工作了。我正在为 Jetty 7 发布更正后的 jetty-web.xml。

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <New id="mysql" class="org.eclipse.jetty.plus.jndi.Resource">
        <Arg>jdbc/mysql</Arg>
        <Arg>
            <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <Set name="driverClass">com.mysql.jdbc.Driver</Set>
                <Set name="jdbcUrl">jdbc:mysql://localhost:3306/mysql</Set>
                <Set name="user">user</Set>
                <Set name="password">pw</Set>
            </New>
        </Arg>
    </New>
</Configure>

在 WEB-INF/lib 中包含以下 jar

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 got the configuration to work now. I'm posting the corrected jetty-web.xml for Jetty 7.

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <New id="mysql" class="org.eclipse.jetty.plus.jndi.Resource">
        <Arg>jdbc/mysql</Arg>
        <Arg>
            <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <Set name="driverClass">com.mysql.jdbc.Driver</Set>
                <Set name="jdbcUrl">jdbc:mysql://localhost:3306/mysql</Set>
                <Set name="user">user</Set>
                <Set name="password">pw</Set>
            </New>
        </Arg>
    </New>
</Configure>

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

生生漫 2024-09-02 01:23:13

检查以确保 OLD jetty-env.xml 不在您的类路径中 -
在 jetty 6 中,jetty-env.xml 以此开头:

<Configure class="org.mortbay.jetty.webapp.WebAppContext">

check to make sure the OLD jetty-env.xml is not in your classpath -
In jetty 6 the jetty-env.xml begins with this:

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文