I am trying to return a JSON object from a jax-rs but I get an internal server error whenever I try to access.
This is my method, I am using javax.ws.rs.GET
.
@GET
@Produces("application/json")
public Testy getJson() {
return new Testy("hello");
}
This is the class:
public class Testy {
private final String value;
public Testy(String value){
this.value = value;
}
public String getValue(){
return value;
}
}
My Pom.xml has this dependency, I have tried various dependencies, but none work. There are various maven resources for jersey, there's jersey-client jersey-core.
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.3.3</version>
</dependency>
I am using Glassfish 4.
Questions about working with Jersey:
I have seen some places where they mention you need to have initialize POJO support, it seems like its for jersey 1.* but I am not sure. I don't need this if I am using 2.* ?
Do I have to modify the web.xml to point to the jersey servlet ?
How can I produce and consume JSON objects using POJO classes !?
Edit
Here is my auto generated config class.