jersey

force glassfish 4 to use jackson 2.3

五迷三道 提交于 2020-01-22 16:17:22
问题 I wrote an maven application which should run on Glassfish 4. The Standard ApplicationConfig looks like this: @javax.ws.rs.ApplicationPath("resources") public class ApplicationConfig extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> resources = new java.util.HashSet<Class<?>>(); // following code can be used to customize Jersey 2.0 JSON provider: try { Class jsonProvider = Class.forName("org.glassfish.jersey.jackson.JacksonFeature"); } catch

force glassfish 4 to use jackson 2.3

寵の児 提交于 2020-01-22 16:16:05
问题 I wrote an maven application which should run on Glassfish 4. The Standard ApplicationConfig looks like this: @javax.ws.rs.ApplicationPath("resources") public class ApplicationConfig extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> resources = new java.util.HashSet<Class<?>>(); // following code can be used to customize Jersey 2.0 JSON provider: try { Class jsonProvider = Class.forName("org.glassfish.jersey.jackson.JacksonFeature"); } catch

Wicket Session and Jersey REST webservice

不想你离开。 提交于 2020-01-21 17:16:29
问题 Currently I'm developing an REST webservice for an PACS viewer (medical images). This webservice needs to have encrypted/obfuscated parameters to ensure users cant fuzz with the parameters to get data from other patients. In an Wicket panel im setting an Session attribute: wicketSession.setAttribute("study", studyInstanceUID); I want to access this attribute in the Jersey webservice, but the session doesn't contain any attributes in my jersey webservice. It seems like it is not injected or

How to use CDI Events in Java Jersey?

送分小仙女□ 提交于 2020-01-21 11:57:22
问题 I am trying to follow this post's upvoted answer: Best practice for REST token-based authentication with JAX-RS and Jersey I'm using the CDI approach and in my filter i have the definition: @Inject @AuthenticatedUser Event<String> userAuthenticatedEvent; But, when I run tomcat 7, I get the following error: org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=Event<String>,parent=AuthenticationFilter,qualifiers={

Print Jersey JSON in Unit Testing

隐身守侯 提交于 2020-01-21 11:17:42
问题 Is there any plain way to print a JAXB annotated instance in JSON format (as exactly jersey will print in AS) while running unit testing without any embedded server launched? I can run and see in XML with JAXBContext, Marshaller, and so on. Is there any example for JSON? I found it. It's similar to JAXB. With Jersey API final JSONJAXBContext context = new JSONJAXBContext(...); final JSONMarshaller marshaller = context.createJSONMarshaller(); marshaller.marshallToJSON(...); final

Can not connect JAX-RS service to MVC template

こ雲淡風輕ζ 提交于 2020-01-21 03:29:05
问题 I'm attempting to make use of JAX-RS' (Jersey) MVC pattern. Attempts to reach http://localhost:8080/myproject/foos/test result in an error that reads: java.io.IOException: The template name, /view, could not be resolved to a fully qualified template name http://localhost:8080/myproject/foos results in the same error. What am I missing? Resource: package resources; import com.sun.jersey.api.view.Viewable; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import

Jersey/Jackson: how to catch json mapping exception?

主宰稳场 提交于 2020-01-20 04:27:24
问题 I would like to catch json mapping exception in my restful service in case input json is not valid. It throws org.codehaus.jackson.map.JsonMappingException , but I don't how to or where to catch this exception. I want to catch this exception and send back appropriate error response. @JsonInclude(JsonInclude.Include.NON_NULL) @Generated("org.jsonschema2pojo") @JsonPropertyOrder({ "name", "id" }) public class Customer { @JsonProperty("name") private String name; @JsonProperty("id") private

REST Webservice returning 415 - Unsupported Media Type

我只是一个虾纸丫 提交于 2020-01-19 05:49:05
问题 I've created a REST webservice using jax-rs and jersey that is supposed to consume JSON on a POST request. My web service class looks like this: @Path("/webhookservice") public class Webhook { @POST @Consumes(MediaType.APPLICATION_JSON) public Response readData (Song song) { // Prints out the song info System.out.println("SONG INFO \n======================="); System.out.println("songname: " + song.getSongname()); System.out.println("artist: " + song.getArtist()); // Repsonse with a HTTP 200

JAX-RS Multipart with com.sun.jersey

假装没事ソ 提交于 2020-01-17 07:16:12
问题 I have a REST service hosted inside Karaf, which is working fine with all requests except for multipart requests. I'm using the com.sun.jersey packages, as I have only succeeded in hosting these inside of Karaf to be accessed over HTTP. When I try to receive the HttpServletRequest inside the POST and call the getParts() method on it, I get the error: IllegalStateException: No multipart config for servlet I have found that I am missing the @MultipartConfig annotation on my servlet, so I added

Serve static content with Jersey 2.22.2

巧了我就是萌 提交于 2020-01-17 06:00:16
问题 I have a REST Api that I developed using Jersey, everything works fine when it comes to Json in / out. and that I'm consuming by Ajax. However, due to Cross-Domain limitations on the browsers, I'd like to package the static website (JS / Images / HTMLs / CSS) on my WAR This is how my web.xml looks like : <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml