嘗試使用Jetty 9.1.4 + Gradle構建Hello World應用程序。 我的項目strucutreIllegalArgumentException:對象不是類的類型org.eclipse.jetty.plus.jndi.Resource
- [項目將root-dir]
-
- [gradle這個]
-
-
- [碼頭-9.1.4]
-
-
-
-
- [LIB]
-
-
-
-
-
- 碼頭-JNDI-9.1.4.v(...)。罐子
-
-
-
-
-
- 碼頭加9.1.4.v(.. 。)/罐
-
-
-
- [SRC]
-
-
- [主要]
-
-
-
-
- 【JAVA]
-
-
-
-
-
-
- [servlet的]
-
-
-
-
-
-
-
-
- HelloWorldServlet。的java
-
-
-
-
-
-
-
- [web應用]
-
-
-
-
-
-
- [WEB-INF]
-
-
-
-
-
-
-
-
- 碼頭-env.xml
-
-
-
-
-
-
-
-
-
- 的web.xml
-
-
-
-
-
- build.gralde
-
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<display-name>HelloWorldServlet</display-name>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>servlet.HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
我的碼頭-env.xml
<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/DSTest</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://sql2.freemysqlhosting.net/sql238625</Set>
<Set name="User">sql238625</Set>
<Set name="Password">gD5%tN5!</Set>
</New>
</Arg>
</New>
我的身材。gradle這個
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'eclipse-wtp'
repositories {
mavenCentral()
}
dependencies {
providedCompile 'javax.servlet:servlet-api:2.5'
compile 'mysql:mysql-connector-java:5.1.30'
runtime 'javax.servlet:jstl:1.1.2'
providedCompile fileTree(dir: 'jetty-9.1.4/lib', include: '*.jar')
}
httpPort = 8080
stopPort = 9451
stopKey = 'foo'
當我執行gradle這個jettyRunWar任務我得到這個例外有堆棧跟蹤:
Failed startup of context [email protected]2cb504{/recipe-beagle,D:\Dev\projects\recipe-beagle\build\libs\recipe-beagle.war}
java.lang.IllegalArgumentException: Object is not of type class org.eclipse.jetty.plus.jndi.Resource
at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:189)
at org.mortbay.jetty.plus.webapp.EnvConfiguration.configureWebApp(EnvConfiguration.java:130)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1269)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
at org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext.doStart(JettyPluginWebAppContext.java:112)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.gradle.api.plugins.jetty.internal.Jetty6PluginServer.start(Jetty6PluginServer.java:111)
at org.gradle.api.plugins.jetty.AbstractJettyRunTask.startJettyInternal(AbstractJettyRunTask.java:240)[...]
所以,這可能是原因,以及如何使其工作?