I created a simple REST service with two resources. The first resource works fine and just returns MediaType.TEXT_PLAIN.
For the second resource, I wanted to try mapping POJOs to Java and follow this example:
https://github.com/jersey/jersey/tree/2.3.1/examples/json-moxy/src/main/java/org/glassfish/jersey/examples/jsonmoxy
with my testbean is defined as:
@XmlRootElement public class Company { public String name; public String symbol; public String country; public Company(String name, String symbol, String country) { this.name = name; this.symbol = symbol; this.country = country; } public String getName() { return name; } public String getSymbol() { return symbol; } public String getCountry() { return country; } }
The resource is also trivial:
@Path("company/{name}") public class CompanyResource { private Map<String, Company> companies; public CompanyResource() { companies = new LinkedHashMap<String, Company>(); companies.put("Apple", new Company("Apple Inc.", "AAPL", "USA")); companies.put("Microsoft", new Company("Microsoft Corp.", "MSFT", "USA")); companies.put("Honda", new Company("Honda Motor Co Ltd", "HMC", "Japan")); companies.put("Random", new Company("Random Inc.", "RND", "Undefined")); } @GET @Produces(MediaType.APPLICATION_JSON) public Company getCompany(@PathParam("name") String name) { Company cmp = companies.get(name); if (cmp == null) { return companies.get("Random"); } return cmp; } }
I debugged the request and returned to the return statement without any problems. From here, however, I think that a JAXBException is being thrown, but I cannot see the details, and nothing appears anywhere in any log. All that happens is that the browser displays the message "500 internal server error."
In the monitoring configuration, I desperately set everything to the HIGH level. Still nothing appears.
The only similar questions I found were jax-rs 2.0 and Glassfish 4, unable to @consume JSON in Pojo and JAX RS Jersey + JSON → HTTP 500 Internal Server Error , but they were not completely related.
For the client, I just use Google Chrome using the "Advanced REST Client" application.
Any help would be greatly appreciated.