My problem is similar to many: I have my application (JT embedded + jersey) and everything Run works. When I try to make an executable jar, I get an error: org.glassfish.jersey.message.internal.WriterInterceptorExecutor $ TerminalWriterInterceptor aroundWriteTo Grave: MessageBodyWriter Media Type = not for application / json Found, type = class my POM.XML:
Monday, 15 April 2013
java - Jersey problems with Maven - Shade Plugin -
After
I encountered the same problem some time ago. The problem is with services files that are not merged, the following work for me:
& lt; Plugin & gt; & Lt; Group & gt; Org.apache.maven.plugins & lt; / Group & gt; & Lt; ArtifactId & gt; Maven-shadow-plugin & lt; / ArtifactId> & Lt; Configuration & gt; & Lt; Transformer & gt; & Lt; Transformer implementation = "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" & gt; & Lt; MainClass & gt; Foo & lt; / MainClass & gt; & Lt; / Transformer & gt; & Lt; Transformer implementation = "org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> & Lt; / Transformer & gt; & Lt; / Configuration & gt; & Lt; / Plugin & gt; The root cause of the problem is that in many jersey-related jars, there is a "services" file in Meta-INF, in which the jersey requires metadata to work properly. By default, the shadow plugin chooses one of these files and incorporates it into a fat jar because the other files do not include metadata, jersey does not work properly. This fix contains an additional transformer when the shadow plugin is applied. This transformer merges data into different files instead of just selecting one of the files, thus, all the required metadata in the desired jar and jersey contains.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment