在 Maven 中运行时 Jetty 失败(说对象类型不正确)

发布于 2024-12-02 02:34:44 字数 4339 浏览 2 评论 0原文

当我尝试在 Maven 构建中启动 Jetty 以便进行 Selenium 测试时,我遇到了异常。

我得到的例外是:

[ERROR] Failed to execute goal org.mortbay.jetty:jetty-maven-plugin:8.0.0.RC0:run (start-jetty) on project THEPROJECTIAMWORKINGON: Failure: Object is not of type class org.eclipse.jetty.webapp.WebAppContext -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.mortbay.jetty:jetty-maven-plugin:8.0.0.RC0:run (start-jetty) on project THEPROJECTIAMWORKINGON: Failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failure
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:358)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
    at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
    ... 19 more
Caused by: java.lang.IllegalArgumentException: Object is not of type class org.eclipse.jetty.webapp.WebAppContext
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:310)
    at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:273)
    at org.mortbay.jetty.plugin.JettyRunMojo.applyJettyXml(JettyRunMojo.java:540)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:289)
    ... 23 more

我目前正在尝试仅使用一个简单的 jetty.xml 来尝试让它工作:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">


</Configure>

并且 pom.xml 中的插件代码目前看起来像这样:

 org.mortbay.jetty;
   jetty-maven-plugin;
   <配置>
     15
     停止我
     9999
   
   <处决>
     <执行>
       开始码头
       <阶段>预集成测试
       <目标>
         <目标>跑
       
       <配置>
         0
         <守护进程>true
         src/test/resources/jetty.xml
       
     
     <执行>
       停止码头
       <阶段>集成后测试
       <目标>
         <目标>停止
       
     
   

有人见过这个吗?或者有什么想法我需要解决?

I am running into an exception when I try to start Jetty within my maven build so I can do selenium testing.

The exception that I am getting is:

[ERROR] Failed to execute goal org.mortbay.jetty:jetty-maven-plugin:8.0.0.RC0:run (start-jetty) on project THEPROJECTIAMWORKINGON: Failure: Object is not of type class org.eclipse.jetty.webapp.WebAppContext -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.mortbay.jetty:jetty-maven-plugin:8.0.0.RC0:run (start-jetty) on project THEPROJECTIAMWORKINGON: Failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failure
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:358)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
    at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
    ... 19 more
Caused by: java.lang.IllegalArgumentException: Object is not of type class org.eclipse.jetty.webapp.WebAppContext
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:310)
    at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:273)
    at org.mortbay.jetty.plugin.JettyRunMojo.applyJettyXml(JettyRunMojo.java:540)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:289)
    ... 23 more

I am currently trying with just a bare bones jetty.xml to try to get it to work:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">


</Configure>

And the plugin code in the pom.xml looks like this at the moment:

   <groupId>org.mortbay.jetty</groupId>
   <artifactId>jetty-maven-plugin</artifactId>
   <configuration>
     <scanIntervalSeconds>15</scanIntervalSeconds>
     <stopKey>stop-me</stopKey>
     <stopPort>9999</stopPort>
   </configuration>
   <executions>
     <execution>
       <id>start-jetty</id>
       <phase>pre-integration-test</phase>
       <goals>
         <goal>run</goal>
       </goals>
       <configuration>
         <scanIntervalSeconds>0</scanIntervalSeconds>
         <daemon>true</daemon>
         <jettyConfig>src/test/resources/jetty.xml</jettyConfig>
       </configuration>
     </execution>
     <execution>
       <id>stop-jetty</id>
       <phase>post-integration-test</phase>
       <goals>
         <goal>stop</goal>
       </goals>
     </execution>
   </executions>

Has anyone ever seen this before? Or have any ideas what I need to fix?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荒人说梦 2024-12-09 02:34:45

好的,经过一段时间的修修补补,我找出了问题所在。我需要在 POM 中使用 jettyEnvXml 而不是 jettyConfig

Ok, so after tinkering for a while I figured out what the problem was. I needed to have jettyEnvXml instead of jettyConfig in my POM

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文