只有当依赖性组装成一个jar子时才会抛出泽西exception

我正在编写一个嵌入Jetty w / Jersey的服务器。 当我从Eclipse执行时,一切都很棒。 但是,如果我使用Maven的程序集将我的服务器和所有依赖项组装到一个jar中:单个目标,我会得到一个例外:

Sep 26, 2012 5:35:59 PM com.sun.jersey.spi.container.ContainerResponse write SEVERE: A message body writer for Java class com.acme.server.webservice. exception.WebServiceFailure, and Java type class com.acme.server.webserv ice.exception.WebServiceFailure, and MIME media type application/json was not fo und Sep 26, 2012 5:35:59 PM com.sun.jersey.spi.container.ContainerResponse write SEVERE: The registered message body writers compatible with the MIME media type are: */* -> com.sun.jersey.server.impl.template.ViewableMessageBodyWriter 17:35:59.372 [qtp184245201-22 - /] ERROR oahReflectorServletProcessor - onReq uest() javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A mess age body writer for Java class com.acme.server.webservice.exception.WebS erviceFailure, and Java type class com.acme.server.webservice.exception. WebServiceFailure, and MIME media type application/json was not found at com.sun.jersey.spi.container.ContainerResponse.write(ContainerRespons e.java:285) ~[vma-server-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na] at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequ est(WebApplicationImpl.java:1457) ~[server-0.0.1-SNAPSHOT-jar-with-dependenc ies.jar:na] 

完整的跟踪在这里,如果它有用: https : //gist.github.com/3790817

Maven在创建jar-with-dependencies时不会抛出任何错误。

我是Maven和Java部署的新手,我真的不确定如何继续调试。

此外,虽然我需要解决这个问题,但我也很欣赏任何建议的解决方法,因为我需要生成我的服务器ASAP的可执行演示,Pointy-Haired Boss(tm)可以在没有Eclipse的情况下执行。

解:

根据Pavel的回答,我删除了maven-assemly-plugin,转而使用maven-shade-plugin。 这是适合我的阴影配置:

   org.apache.maven.plugins maven-shade-plugin 2.0   package  shade          *:*  META-INF/*.SF META-INF/*.DSA META-INF/*.RSA        

你没有正确合并泽西岛jar子。

Jersey 1.x使用META-INF /服务机制来发现它的组件和程序集:single可能只是将所有内容复制到单个jar中,覆盖已经存在的文件但是META-INF / services文件需要被连接。

尝试使用jersey-bundle( com.sun.jersey:jersey-bundle:1.14 )或修复你的程序集设置(或找到另一个插件来做得更好)。

你能发贴你的pom吗?

您是否标记了提供的某些依赖项? 建立一个独立的应用程序和一个webapp是完全不同的,因为一些应该由Web容器(tomcat或其他)提供的jar。

由于您的容器“嵌入”在您的应用程序中(而不是容器中的应用程序),因此您可能无法正确管理这些依赖项。