我正在尝试使用jetty gradle插件运行Jetty服务器进行功能测试。但是,我得到了java.lang.IllegalArgumentException: Object is not of type class org.mortbay.jetty.webapp.WebAppContext
。
我遵循了here所示的示例,看不到我在做什么。构建文件的相关部分如下所示:
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>
可以在here中找到stacktrace。
任何建议将不胜感激。
最佳答案
我最好的猜测是,这是Jetty插件中的错误。通常,Jetty插件非常有限且已过时,建议改用arquillian-gradle-plugin。这就是Gradle的容器支持的方向。
关于jetty - 尝试使用Gradle插件启动 jetty 服务器时发生IllegalArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18056245/