jersey

org.glassfish.jersey.server.ContainerException: java.io.IOException: Stream closed

社会主义新天地 提交于 2019-12-23 17:43:52
问题 I have register two ContainerRequestFilter filters and one ContainerResponseFilter in my application class that extends a JAX-RS Application: filters as : register(LoggingResponseFilter.class); register(AuthorizationRequestFilter.class); register(LikeRequestFilter.class); and when I tries to call a targeted method resource I have an Exception. Resource method as : @Override @POST @Path("/{userId}/like") @TokenResource @GMTResource // to validate GMT of client and server @Like // for like

Jersey: Is there a clean way to specify allowed URL extensions?

為{幸葍}努か 提交于 2019-12-23 17:30:16
问题 I'm using Jersey 1.17.1 and on every URL I've created I want to allow people to put ".json" at the end or not. Here's an example of what I've done: @GET @Path("basepath{extension: (\\.json)?}") public String foobar() { ... } Eventually I'm going to let them choose between nothing, ".json" or ".xml" and I'm concerned about my DRY violation here. I'll have to change every @Path to this instead: @GET @Path("basepath{extension: (\\.json|\\.xml)?}") public String foobar() { ... } Is there a better

Implement a JUnit test for a rest service

橙三吉。 提交于 2019-12-23 17:28:06
问题 I have to implement some JUnit tests for my rest services. For instance this is one of my Rest services: @Path("/dni-fe") public class HelloWorld { @POST @Path("/home") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public MachineResponse doMachineRegister(MachineBean machineBean) { MachineResponse response = new MachineResponse(); String name = machineBean.getName(); String country = machineBean.getCountry(); String company = machineBean.getCompany(); String

Getting error on pubsub example using Atmosphere + Jersey

十年热恋 提交于 2019-12-23 16:35:40
问题 I'm following the tutorial here http://jfarcand.wordpress.com/2011/06/29/rest-websocket-applications-why-not-using-the-atmosphere-framework/ I already have a Jersey project up and running and working fine using JBoss 7. The one difference i have is that i am using Jersey with Spring. So my JQueryPubSub looks like this @Service <-- For Spring component Scan @Path("/pubsub/{topic}") @Produces("text/html;charset=ISO-8859-1") public class JQueryPubSub { @PathParam("topic") Broadcaster topic; @GET

Java Jersey RESTful web service using https

∥☆過路亽.° 提交于 2019-12-23 16:15:37
问题 I am new to Java EE and I am developing a RESTful api in wich every api call the user sends encoded credentials. My problem is how to implement https protocol over default http and make my connection secure. I am using Jersey restful web services and Glassfish web server. Thanks. 回答1: That's more a setup/configuration question, isn't it? You use HTTPS (TLS) because you set it up in your server, then your REST endpoint will be used/changed accordingly...and the (encoded) credentials can be

Jax-RS not registering resource with @provider annotation

蓝咒 提交于 2019-12-23 12:38:55
问题 I have a rest application running in weblogic 12c using jersey api. I have a http request filter class with an annotation @provider. however when deploying the application the filter class is not registered with the other resource classes that I have added in my ApplicationConfig class. and subsequently I am not able to filter the http requests. below are my logs and the code Sep 01, 2015 11:16:12 AM weblogic.jaxrs.server.portable.servlet.JerseyServletContainerInitializer onStartup INFO:

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map; when deploying jersey ws to Weblogic

时光总嘲笑我的痴心妄想 提交于 2019-12-23 12:09:03
问题 I'm deploying a web service application on Weblogic 12. The application uses jersey and thus depends on javax.ws.rs-api:2.0.1 library. However when I deploy it to server I have a following error : Caused By: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map; at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285) at org.glassfish.jersey

Serving static content with Jetty/Jersey/Guice

亡梦爱人 提交于 2019-12-23 12:06:43
问题 Similar to another question (cf. Filtering static content Jersey) I want to serve static content from Jetty. There are several similar questions scattered all around the vast Internet, but most of them do not involve Guice, and those that do are completely out of date. I have an existing service that uses Jersey (1.12) and Guice (3) with the following web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema

HK2 MethodInterceptor with Jersey resource

半城伤御伤魂 提交于 2019-12-23 10:34:17
问题 How can I set up an aop MethodInterceptor to work with Jersey resources? Here is what I've tried, following this documentation: Step 1 - InterceptionService public class MyInterceptionService implements InterceptionService { private final Provider<AuthFilter> authFilterProvider; @Inject public HK2MethodInterceptionService(Provider<AuthFilter> authFilterProvider) { this.authFilterProvider = authFilterProvider; } /** * Match any class. */ @Override public Filter getDescriptorFilter() { return

HK2 MethodInterceptor with Jersey resource

回眸只為那壹抹淺笑 提交于 2019-12-23 10:34:03
问题 How can I set up an aop MethodInterceptor to work with Jersey resources? Here is what I've tried, following this documentation: Step 1 - InterceptionService public class MyInterceptionService implements InterceptionService { private final Provider<AuthFilter> authFilterProvider; @Inject public HK2MethodInterceptionService(Provider<AuthFilter> authFilterProvider) { this.authFilterProvider = authFilterProvider; } /** * Match any class. */ @Override public Filter getDescriptorFilter() { return