Link to home
Start Free TrialLog in
Avatar of SheppardDigital
SheppardDigital

asked on

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

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
ASKER CERTIFIED SOLUTION
Avatar of SheppardDigital
SheppardDigital

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SheppardDigital
SheppardDigital

ASKER

Resolved myself.