开发者

Jetty 7 + MySQL Config [java.lang.IllegalArgumentException: Object is not of type class org.eclipse.jett y.webapp.WebAppContext]

I've been trying to get a c3p0 db connection pool configured for Jetty (7.4.1.v20110513), but I keep getting a 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.d开发者_如何学Ceploy.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

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

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.6.jar
mysql-connector-java-5.1.16-bin.jar

Someone please tell me what is wrong with my configuration.


Your jetty-web.xml is still referring to org.mortbay.* which is for Jetty 6.

For Jetty 7,change

org.mortbay.jetty.webapp.WebAppContext to org.eclipse.jetty.webapp.WebAppContext

and

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


Are you sure that you do not have jetty twice in classpath ? In you case the second instance would be in your application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜