NoClassDef-s再次使用Eclipse Jetty的Maven插件

时间:2014-04-04 00:55:18

标签: java maven jetty

请有人帮助我,我绝望了。我整夜都在努力。我遇到的问题是:Weird NoClassDef-s with Eclipse Jetty's Maven plugin

基本上:我无法使最新版本的Jetty插件在集成测试中正常工作。事实上,一切正常,直到Jetty的关闭阶段,当我告诉org.eclipse.jetty.util.FutureCallback缺失时。

我已经在上面的链接中包含了依赖关系。最初他们被忽略了,然后我在项目/构建/扩展中添加了它们。现在我还有其他几个ClassNotFoundExceptions,我无法解决这个问题。

这就是我在POM中所拥有的:

<plugins>

        <!-- This is activated before tests and uses the overlay import mechanism -->
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>

            <configuration>

                <systemProperties>
                    <!-- Triggers test data creation in uk.ac.ebi.fg.myequivalents.webservices.server.test.WebTestDataInitializer -->
                <systemProperty>
                    <name>uk.ac.ebi.fg.myequivalents.test_flag</name>
                  <value>true</value>
                </systemProperty>
                </systemProperties>         

                <scanIntervalSeconds>10</scanIntervalSeconds>
                <useTestScope>true</useTestScope>

              <httpConnector>
                <!-- 8080 is often busy on EBI hosts -->
                <port>10973</port>
              </httpConnector>

                <stopPort>10974</stopPort>
        <stopKey>KILL</stopKey>

            </configuration>

            <executions>
                <!-- 
                    starts jetty before tests and stops it afterwards. Note that no stop goal is needed, it magically stops
                    after tests 
                -->
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                </goals>
                    <configuration>
                      <scanIntervalSeconds>0</scanIntervalSeconds>
                      <daemon>true</daemon>
                    </configuration>
                </execution>
                <execution>
                <id>stop-jetty</id>
                <phase>post-integration-test</phase>
                <goals>
                <goal>stop</goal>
                </goals>
                </execution>                    
            </executions>
        </plugin>

这些是我设置的例子:

        <extensions>
        <extension>
            <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-util</artifactId>
            <version>${jetty.version}</version>             
        </extension>        
        <extension>
            <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-jsp</artifactId>
            <version>${jetty.version}</version>             
        </extension>        
        <extension>
            <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-io</artifactId>
            <version>${jetty.version}</version>             
        </extension>        
        <extension>
            <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-jaspi</artifactId>
            <version>${jetty.version}</version>             
        </extension>        
    </extensions>

$ {jetty.version}在父级和= 9.1.3.v20140225中定义,但我尝试过多次,低至7.x

此外,Maven是3.2.1,Java是1.7.0_51,在OS X 10.9.2上运行

提前感谢您对这个讨厌问题的任何帮助。

3 个答案:

答案 0 :(得分:2)

我找到了!!!显然,问题是“停止&#39;目标是(正确地)附在“整合后测试”之后。相。因此,如果你发布了“集成 - 测试”这一阶段,据我所知,这一阶段未达到(http://tinyurl.com/omwulm5)。只需提供“验证”即可。或者&#39;安装&#39;,并且不向POM添加任何与Jetty相关的依赖(现在所需的一切都应该包含在9.1.x中),Maven没有任何投诉就完成了(万岁!)。

对于比我更聪明的读者来说,这可能看起来很愚蠢,尽管如此,我仍在报道,以防万一你和我刚刚做了几个小时一样挣扎。

答案 1 :(得分:2)

您不应该使用执行绑定的“运行”目标。相反,你应该使用“开始”目标。请参阅此处的文档:http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#jetty-start-goal

不同之处在于“运行”目标将在“测试 - 编译”阶段之前进行新的构建。 “开始”目标不会调用并行构建,只是在绑定的任何阶段运行。

答案 2 :(得分:0)

尝试将<stopWait>10</stopWait>添加到插件配置中。

您可以在this answer中看到完整配置。