Reputation: 61
I try build maven-project in NetBeans. In project I use jersey-media-json-jackson. My dependencies look like that
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.23.1</version>
</dependency>
And if I run project in IDE all work correctly. But if I build project with dependencies and run resulting jar-file I am having the following error
org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/json, type=class com.ats.orion.client.model.req.UpdateContextRequest, genericType=class com.ats.orion.client.model.req.UpdateContextRequest.
Exception in thread "main" org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class com.ats.orion.client.model.req.UpdateContextRequest, genericType=class com.ats.orion.client.model.req.UpdateContextRequest.
The same exception appear in IDE when I comment jersey-media-json-jackson dependency.
My build block in pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.ats.test.App</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>
</plugins>
</build>
How to solve my problem?
Upvotes: 2
Views: 2018
Reputation: 631
This might be happening because of the way Jersey discovers and registers features automatically. Putting everything into a fat jar can cause issues with this auto-discovery and registration and you might have to do it manually.
Refer this answer to a very similar question, only in your case the statement to register Jersey's Jackson feature would probably be
jerseyServlet.setInitParameter(
"jersey.config.server.provider.classnames",
"org.glassfish.jersey.jackson.JacksonFeature");
Upvotes: 2