Tomcat 9 - application / json was not found

1

Greetings,

I'm developing a WS in Jersey / Restful which is working correctly on Glassfish but on Tomcat I get the error trying to consume the service.

  

SEVERE: Mapped exception to response: 500 (Internal Server Error)   javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.util.ArrayList, and Java type java.util.ArrayList, and MIME media type application / json was not found       at com.sun.jersey.spi.container.ContainerResponse.write (ContainerResponse.java:285)       at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest (WebApplicationImpl.java:1437)

Only occurs with "application / json" produces or MediaType.APPLICATION_JSON already with "text / html" does not give tomcat error.

Has anyone ever gone through this?!

[]'s

    
asked by anonymous 08.03.2017 / 22:02

1 answer

0

The explanation ...

  

We need to tell Jersey that the java class should be converted to Json, checking specifications such as setter / getter classes, whether present or not.

    <dependency>
        <groupId>com.owlike</groupId>
        <artifactId>genson</artifactId>
        <version>1.3</version>
    </dependency> 

What I did not understand was why I only need Tomcat since in Glassfish it ran without error ... but it is for another search ...

[]'s

source: link (in questions and answers to the question )

    
09.03.2017 / 18:30