I have an ember application trying to make a post request to my Restful Java Web Service (JAX-RS). However, the request doesn't seem to be hitting the endpoint. Instead, the Java web service is sending the following response to ember:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://wadl.dev.java.net/2009/02">
<doc xmlns:jersey="http://jersey.java.net/" jersey:generatedBy="Jersey: 1.10 11/02/2011 04:41 PM"/>
<grammars/>
<resources base="http://localhost:3002/">
<resource path="users">
<method id="postUser" name="POST">
<response>
<representation mediaType="application/json"/>
</response>
</method>
</resource>
</resources>
</application>
The web service itself prints the following message to the console
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class javax.ws.rs.core.Response
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class javax.ws.rs.core.Response
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class javax.ws.rs.core.Response
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class java.lang.String
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class javax.ws.rs.core.Response
The endpoint on JAX-RS looks like this:
@Path("/users")
public class Users {
@POST
@Produces("application/json")
public Response postUser() {
System.out.println("here");
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{}").header("Access-Control-Allow-Origin", "*").build();
}
}
Jersey Version: jax-rs-jersey-1.10
The adapter in ember looks like this:
export default DS.RESTAdapter.extend({
host: 'http://localhost:3002',
});
Thank you in advance!
Edit: When testing the request in postman, it all works with no issues. Could be something to do with headers in ember?
The issue was that the client was making the OPTIONS request to check if the server responded with CORS, and the JAX-RS wasn't set up for CORS.
The solution was to write the CORS filter and then to update Jersy to 2.22. Therefore changing the HTTPServer setup to JdkHttpServerFactory