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
Java

Avatar of undefined
Last Comment
SheppardDigital

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
SheppardDigital

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SheppardDigital

ASKER
Resolved myself.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck