jax-rs

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

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

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

java.lang.NoSuchMethodError: org.eclipse.persistence.oxm.XMLUnmarshaller.setNamespaceResolver(Lorg/eclipse/persistence/oxm/NamespaceResolver;)

放肆的年华 提交于 2020-01-17 04:16:06
问题 I am writing jax-rs restful application using jersey(, GET request was fine but POST, PUT & DELETE request give the error below SEVERE: Servlet.service() for servlet [Jersey Web Application] in context with path [/RESTful_JaxRS] threw exception [org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: org.eclipse.persistence.oxm.XMLUnmarshaller.setNamespaceResolver(Lorg/eclipse/persistence/oxm/NamespaceResolver;)V] with root cause java.lang.NoSuchMethodError: org.eclipse

JAX-RS Rest Filter does not invoke

社会主义新天地 提交于 2020-01-16 19:59:53
问题 I have an api that needs to implement security. But the filter is not invoked. my call pass directly to the endpoint... My Secure interface @NameBinding @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE,ElementType.METHOD}) public @interface Seguro {} My Filter @Seguro @Provider @Priority(Priorities.AUTHENTICATION) public class FiltroAutenticacao implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { String

Multipart formdata not working with Jersey and JaxRs

那年仲夏 提交于 2020-01-16 19:09:49
问题 I want to build support for fileupload using Jersey (2.22.2) & JaxRs. This is my application: @ApplicationPath("rest") public class DsmJaxRsApplication extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> classes = new HashSet<>(); classes.add(FileUploadResource.class); classes.add(MultiPartFeature.class); return classes; } } This is my resource method to intercept the POST request: @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.TEXT_PLAIN)

Java Rest API: how to check connection between client and endpoint?

江枫思渺然 提交于 2020-01-16 05:47:05
问题 How I can check if user who sent rest request aborted it using Ctrl-C? I need to check it on server side because it takes several minutes. If user aborted it then I should stop it. I tried to write to ServletOutputStream but it doesn't work (I never catch exception): @Path("test") public void test(@Context MessageContext mc) { try { ServletOutputStream out = mc.getHttpServletResponse().getOutputStream(); out.println("test"); out.flush(); } catch (IOException e) { System.out.println(

JBOSS AS7 jax-rs jaas and annotations

做~自己de王妃 提交于 2020-01-16 00:46:35
问题 Hey I hope someone can help tried for last 2 days to figure out what I am doing wrong. I want a programmatic login to a JAX-RS api and to use @RolesAlowed annotations on my endpoints. I login fine and can see the principal set in the login endpoint also I get a JSESSIONID. But when I call the /info/ping endpoint that is annotated with @RolesAllowed("USER") it throws UnauthenticatedException. If I remove the annotation then the req.getUserPrincipal() is null event though the cookie set. Any