Java NoClassDefFoundError:使用DropWizard时org/eclipse/jetty/io/ByteBufferPool

Java NoClassDefFoundError:使用DropWizard时org/eclipse/jetty/io/ByteBufferPool,java,maven,jetty,dropwizard,Java,Maven,Jetty,Dropwizard,我目前正在尝试运行dropwizard()的入门应用程序。我可以使用mvn软件包构建jar文件,但是当我运行该文件(java-jar-target/my-project-0.0.1-SNAPSHOT.jar)时,我得到一个错误: 线程“main”java.lang.NoClassDefFoundError中出现异常: org/eclipse/jetty/io/ByteBufferPool 以下是我的pom.xml: 4.0.0 com.example 我的项目 0.0.1-快照 io.dro

我目前正在尝试运行dropwizard()的入门应用程序。我可以使用mvn软件包构建jar文件,但是当我运行该文件(java-jar-target/my-project-0.0.1-SNAPSHOT.jar)时,我得到一个错误:

线程“main”java.lang.NoClassDefFoundError中出现异常: org/eclipse/jetty/io/ByteBufferPool 以下是我的pom.xml:


4.0.0
com.example
我的项目
0.0.1-快照
io.dropwizard
dropwizard核心
${dropwizard.version}
UTF-8
UTF-8
0.7.0
org.apache.maven.plugins
maven编译器插件
3.1
1.7
1.7
UTF-8
org.apache.maven.plugins
maven阴影插件
1.6
真的
*:*
META-INF/*.SF
META-INF/*.DSA
META-INF/*.RSA
包裹
阴凉处
com.example.helloworld.helloworld应用程序
org.apache.maven.plugins
maven jar插件
2.4
真的

我没有太多的maven配置经验,所以我看不出任何错误。我所有的消息来源似乎都在正确的地方。谢谢你的建议

编辑:

在pom中添加了OF399991的建议后,我注意到在运行mvn包或安装时出现了一个警告(虽然已经存在,但没有那么清楚):

[WARNING] The POM for org.eclipse.jetty:jetty-server:jar:9.0.7.v20131107 is invalid,
transitive dependencies (if any) will not be available: 1 problem was encountered while 
building the effective model for org.eclipse.jetty:jetty-server:9.0.7.v20131107

[FATAL] Non-parseable POM /home/yenox/.m2/repository/org/eclipse/jetty/jetty-
parent/20/jetty-parent-20.pom: end tag name </body> must match start tag name <hr> from 
line 5 (position: TEXT seen ...</center>\r\n</body>... @6:8)  @ 
/home/yenox/.m2/repository/org/eclipse/jetty/jetty-parent/20/jetty-parent-20.pom, line 6, 
column 8
[警告]org.eclipse.jetty:jetty服务器:jar:9.0.7.v20131107的POM无效,
可传递依赖项(如果有)将不可用:在运行时遇到1个问题
为org.eclipse.jetty构建有效的模型:jetty服务器:9.0.7.v20131107
[致命]不可解析的POM/home/yenox/.m2/repository/org/eclipse/jetty/jetty-
parent/20/jetty-parent-20.pom:结束标记名称必须与起始标记名称相匹配
第5行(位置:看到文本…\r\n…@6:8)@
/home/yenox/.m2/repository/org/eclipse/jetty/jetty parent/20/jetty-parent-20.pom,第6行,
第8栏

您需要确保使用maven构建的jar包含所有dropwizard库。我建议您检查构建的jar文件,看看它是否包含这些内容

如果没有,则需要在标记之间向pom.xml文件添加类似的内容:

   <plugin>
     <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <configuration>
        <archive>
        <manifest>
           <mainClass>com.wibblewobble</mainClass>
        </manifest>
        </archive>
        <descriptorRefs>
              <descriptorRef>jar-with-dependencies</descriptorRef>
         </descriptorRefs>
         </configuration>
         <executions>
             <execution>
             <id>make-assembly</id>
             <phase>package</phase>
             <goals>
             <goal>single</goal>
             </goals>
             </execution>
        </executions>
        </plugin>

您可能会得到两个jar,但您要运行的jar将被称为wibblewobble-1.0-jar-with-dependencies。

我最终删除了.m2/repository中包含依赖项的文件夹,然后进行了mvn干净安装,一切恢复正常

编辑:
我想我知道错误的来源:在切换到maven3之前,我首先使用了maven2,它可能会弄乱我的存储库。

您是否尝试过使用Maven进行安装?您是说在另一个项目上?不是在这台机器上,不。好的,这台机器不会有什么用处。我认为你需要在这个项目上运行install来获得dependenciesI,不过我在这个项目上安装了mvn。因此,如果已经安装了,你应该在那里发布你所做的实际代码。这个问题可能不一定与pom文件有关..我仍然有错误,但在尝试您的解决方案时,我注意到多次显示警告。我把它放在编辑栏里。
mvn package assembly:single