Jetty 7 + MySQL Config [java.lang.IllegalArgumentException:



我一直在尝试为 Jetty (7.4.1.v20110513( 配置一个 c3p0 db 连接池,但我不断得到一个 java.lang.IllegalArgumentException :

C:jetty7>java -jar start.jar
2011-05-29 00:29:51.843:INFO::jetty-7.4.1.v20110513
2011-05-29 00:29:51.875:INFO::Deployment monitor C:jetty7webapps at interval 1
2011-05-29 00:29:51.890:INFO::Deployable added: C:jetty7webappsblock
2011-05-29 00:29:52.093:INFO::started o.e.j.w.WebAppContext{/block,file:/C:/jett
y7/webapps/block/},C:jetty7webappsblock
2011-05-29 00:29:52.171:INFO::Deployable added: C:jetty7webappshello
2011-05-29 00:29:53.000:WARN::Failed startup of context o.e.j.w.WebAppContext{/h
ello,file:/C:/jetty7/webapps/hello/},C:jetty7webappshello
java.lang.IllegalArgumentException: Object is not of type class org.eclipse.jett
y.webapp.WebAppContext
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configur
e(XmlConfiguration.java:310)
        at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.jav
a:273)
        at org.eclipse.jetty.webapp.JettyWebXmlConfiguration.configure(JettyWebX
mlConfiguration.java:88)
        at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:4
23)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.jav
a:1192)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandle
r.java:586)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:449
)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife
Cycle.java:58)
        at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(Stan
dardStarter.java:36)
        at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:1
80)
        at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentM
anager.java:482)
        at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.j
ava:135)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(Scan
ningAppProvider.java:137)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(Sc
anningAppProvider.java:50)
        at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:601)
        at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
        at org.eclipse.jetty.util.Scanner.scan(Scanner.java:394)
        at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:329)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife
Cycle.java:58)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(Scanni
ngAppProvider.java:114)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife
Cycle.java:58)
        at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(Deploymen
tManager.java:543)
        at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.
java:218)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife
Cycle.java:58)
        at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(Aggregate
LifeCycle.java:41)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHand
ler.java:50)
        at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrappe
r.java:90)
        at org.eclipse.jetty.server.Server.doStart(Server.java:258)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife
Cycle.java:58)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:11
97)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:112
0)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:469)
        at org.eclipse.jetty.start.Main.start(Main.java:604)
        at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:265)
        at org.eclipse.jetty.start.Main.main(Main.java:79)
2011-05-29 00:29:53.046:INFO::Deployment monitor C:jetty7contexts at interval
1
2011-05-29 00:29:53.046:INFO::Deployable added: C:jetty7contextstest.xml
2011-05-29 00:29:53.125:INFO::Extract jar:file:/C:/jetty7/webapps/test.war!/ to
C:Documents and SettingsWelcomeLocal SettingsTempjetty-0.0.0.0-8080-test.wa
r-_-any-webapp
2011-05-29 00:29:54.062:INFO::started o.e.j.w.WebAppContext{/,file:/C:/Documents
%20and%20Settings/Welcome/Local%20Settings/Temp/jetty-0.0.0.0-8080-test.war-_-an
y-/webapp/},C:jetty7/webapps/test.war
2011-05-29 00:29:56.015:INFO:org.eclipse.jetty.servlets.TransparentProxy:Transpa
rentProxy @ /javadoc to http://download.eclipse.org/jetty/stable-7/apidocs
2011-05-29 00:29:56.015:INFO::Deployable added: C:jetty7contextsjavadoc.xml
2011-05-29 00:29:56.046:INFO::started o.e.j.s.h.ContextHandler{/javadoc,file:/C:
/jetty7/javadoc}
2011-05-29 00:29:56.125:INFO::Started SelectChannelConnector@0.0.0.0:8080 STARTI
NG

这是我的 web-INF 目录中的 web.xml 和 jetty-web.xml 文件。

码头网.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>

网站.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>cs</servlet-name>
        <servlet-class>cs</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>cs</servlet-name>
        <url-pattern>/servlet</url-pattern>
    </servlet-mapping>
    <servlet>
    <servlet-name>Quercus Servlet</servlet-name>
    <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
    </servlet>
<servlet-mapping>
    <servlet-name>Quercus Servlet</servlet-name>
    <url-pattern>*.php</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.php</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

目前,我已经在我的 WEB-INF/lib 目录中放置了以下 jar:

c3p0-0.9.1.2.jar
commons-dbcp-1.4.jar
commons-pool-1.5.6.jar
mysql-connector-java-5.1.16-bin.jar

有人请告诉我我的配置有什么问题。

你的码头网.xml仍然指的是org.mortbay.*,这是针对码头6的。

对于 7 号码头,更改

org.mortbay.jetty.webapp.WebAppContextorg.eclipse.jetty.webapp.WebAppContext

org.mortbay.jetty.plus.naming.Resourceorg.eclipse.jetty.plus.jndi.Resource .

你确定你在类路径中没有两次码头吗?在您的情况下,第二个实例将位于您的应用程序中。

相关内容

最新更新