尝试使用gradle插件启动jetty服务器时出现IllegalArgumentException



我正在尝试使用jetty-gradle插件来运行jetty服务器进行功能测试。然而,我得到了java.lang.IllegalArgumentException: Object is not of type class org.mortbay.jetty.webapp.WebAppContext

我遵循了这里的例子,看不出我在做什么不同。构建文件的相关部分如下所示:

apply plugin: 'jetty'
dependencies {
    providedRuntime 'com.h2database:h2:1.3.167'
    providedRuntime 'commons-dbcp:commons-dbcp:1.4'
}
jettyRunWar {
  httpPort = 8083
  stopPort = 8085
  stopKey = "stopKey"
  jettyConfig = file("$projectDir/jetty-config/jetty.xml")
}
jettyStop {
  stopPort = 8085
  stopKey = "stopKey"
}

我的jetty.xml看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
 <Set name="contextPath">/gateway</Set>
 <New class="org.mortbay.jetty.plus.naming.Resource">
     <Arg>
     </Arg>
     <Arg>jdbc/gateway</Arg>
     <Arg>
         <New class="org.apache.commons.dbcp.BasicDataSource">
             <Set name="url">jdbc:h2:tcp://localhost/build/db; USER=sa</Set>
         </New>
     </Arg>
 </New>
</Configure>

堆叠跑道可以在这里找到。

如有任何建议,我们将不胜感激。

我的最佳猜测是这是Jetty插件中的一个bug。总的来说,Jetty插件是非常有限和过时的,我建议尝试arquillian-gradle插件。这就是Gradle的容器支持的发展方向。

最新更新