Severe:   MessageBodyWriter not found for media type=application/json

SheppardDigital
SheppardDigital used Ask the Experts™
on
Hi,

I'm just starting out with Java and I'm trying to build a simple API.

The issue I'm having is that I'm getting this message when trying to return an Object as JSON.

Severe:   MessageBodyWriter not found for media type=application/json

I've setup the application with Maven, and as a result of some research I've added the following dependancies to the pom.xml file in the hope that it would resolve the issue.

<dependency>
            <groupId>com.owlike</groupId>
            <artifactId>genson</artifactId>
            <version>0.99</version>
        </dependency>
        
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>2.8</version>
        </dependency>

Open in new window


The method I have which is trying to return the Object as JSON is as follows;
@GET
    @Produces("application/json")
    public Person getAll() {
        Person me = new Person("John", "Doe", "test@test.com");
        
        return me;
    }

Open in new window


Can anyone see where I'm going wrong? Do I need to add anything to the web.xml file to make it work?java
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I've just changed Genson to the latest version, and the problem is fixed.

Author

Commented:
Resolved myself.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial