gpt4 book ai didi

java - jetty 7 + MySQL 配置 [java.lang.IllegalArgumentException : Object is not of type class org. eclipse.jett y.webapp.WebAppContext]

转载 作者:行者123 更新时间:2023-11-29 01:32:50 24 4
gpt4 key购买 nike

我一直在尝试为 Jetty (7.4.1.v20110513) 配置一个 c3p0 数据库连接池,但我一直收到 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:\jetty7\webapps at interval 1

2011-05-29 00:29:51.890:INFO::Deployable added: C:\jetty7\webapps\block
2011-05-29 00:29:52.093:INFO::started o.e.j.w.WebAppContext{/block,file:/C:/jett
y7/webapps/block/},C:\jetty7\webapps\block
2011-05-29 00:29:52.171:INFO::Deployable added: C:\jetty7\webapps\hello
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:\jetty7\webapps\hello
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:\jetty7\contexts at interval
1
2011-05-29 00:29:53.046:INFO::Deployable added: C:\jetty7\contexts\test.xml
2011-05-29 00:29:53.125:INFO::Extract jar:file:/C:/jetty7/webapps/test.war!/ to
C:\Documents and Settings\Welcome\Local Settings\Temp\jetty-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:\jetty7\contexts\javadoc.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 文件。

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" 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

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

最佳答案

您的 jetty-web.xml 仍然指的是用于 Jetty 6 的 org.mortbay.*

对于 Jetty 7,更改

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

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

关于java - jetty 7 + MySQL 配置 [java.lang.IllegalArgumentException : Object is not of type class org. eclipse.jett y.webapp.WebAppContext],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6163951/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com