jersey

How to access multiple resources in a single request : Jersey Rest

邮差的信 提交于 2019-12-25 04:15:44
问题 I am trying to a find a good design for the following scenario. I have a POST rest service which will be given an array of services as data. And which should in turn be calling them one by one to aggregate results on the server and send them back to the client. @Path("/resource1") @Path("/resource2") @Path("/collection") Post data to /collection {["serviceName": "resource1", "data":"test1"], ["serviceName":"resource2","data":"test2"]} The reason i need the resource1 and resource2 are, because

Jersey Jackson root name coming as ArrayList

独自空忆成欢 提交于 2019-12-25 03:55:32
问题 I have an array list of objects. ArrayList. The Employee class is annotated with @XMLRootElement(name = "employees"). I use jersey 1.8.1, Jackson 1.9.2 with POJOMappingFeature.The response is like { ArrayList: [{name: John, age: 28}, {name: Mike, age:29}] } How do i make jackson display the correct root name (employees) in the json response. i tried using @JsonName(value = "employees") on Employee class also. I need to do this without using a list wrapper like EmployeeListWrapper with

Tomcat 7 + Jersey 2.0 error

情到浓时终转凉″ 提交于 2019-12-25 03:30:27
问题 java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder; at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:289) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain

Install custom Jersey ViewProcessor from Guice ServletModule

倖福魔咒の 提交于 2019-12-25 03:05:27
问题 I am using jersey-guice to set up all my Jersey 1 resources using a bunch of Guice (Servlet)Modules. I have written a custom ViewProcessor ( CustomViewProcessor ) that relies on a configuration object, that I want to be injected into it using Guice. This CustomViewProcessor should be picked up and used by Jersey every time it needs one. How do I tell Jersey to fetch a Guice-created CustomViewProcessor instance whenever it needs a ViewProcessor ? I want to set all this up within my Guice

How to send response as JSON in Jersey Rest

前提是你 提交于 2019-12-25 02:48:54
问题 I have Jersey Rest Webservice with server side code as @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public List<Employee> getEmployees() { return new EmployeeService().getEmployees(); } T I am testing the service from chrome rest client. This works fine with Accept: application/xml ** But when I am requesting this with code Accept: application/json I am getting the following exception:- javax.servlet.ServletException: org.glassfish.jersey.message.internal

Jersey resource not found

可紊 提交于 2019-12-25 02:41:12
问题 Trying Jersey for the first time, I've quickly run into a problem that I can't figure out. I have two resources in the same package, following the same blueprint, but at runtime, Jersey only finds one of them. I have checked that both classes exist in the same folder in the jar included in the war. Update: If I remove the @Path annotation on DashboardResource (effectively removing the resource), then DetailsResource suddenly comes to life. It seems like details is hidden by dashboard in some

Integrating both spring mvc and Jersey, getting a null pointer when viewing a jersey endpoint

拥有回忆 提交于 2019-12-25 02:11:51
问题 My simple jersey endpoint: @Component @Path("/v1/user") public class UserService { @Autowired com.myapp.core.service.UserService userService; @GET @Path("/get") public Response getUser() { User user = userService.getUser(1); String result = user.getUsername(); return Response.status(200).entity(result).build(); } } (BTW, since this is restful, will this be an xml or json output??) My spring mvc pages working fine (that hit hibernate), but when I visit localhost:8080/api/v1/user/get I see:

Jetty How to add a servlet to multiple ServletContextHandler or apply ContainerRequestFilter to ContextHandlerCollection

≯℡__Kan透↙ 提交于 2019-12-25 01:49:35
问题 I need to intercept all the requests when there are multiple ServletContextHandler configured. I have multiple ServletContextHandler in a ContextHandlerCollection and a ContainerRequestFilter . I need this ContainerRequestFilter to be added to all ServletContextHandler Only way I could find of adding the ContainerRequestFilter was through ResourceConfig . So I did this: ResourceConfig resourceConfig = new ResourceConfig(); resourceConfig.register(MyContainerRequestFilter.class); ServletHolder

Proxy setting not working in Jersey ClientConfig

怎甘沉沦 提交于 2019-12-25 01:45:01
问题 I'm trying to setup a proxy in my java code using Jersey client but the proxy is not getting set. I went through the Jersey documentation and have implemented the code in the described way. I'm new to Jersey so not sure where I'm going wrong. Below is the code. @Override @CircuitBreaker(name = "documentServiceCreateDocument", ignore = { NullPointerException.class, ArrayIndexOutOfBoundsException.class }) public String createDocument(String name, DocumentType docType, List<SourceData>

Getting the error “No bean named 'springSecurityFilterChain' available” in Spring/Jersey webapp

主宰稳场 提交于 2019-12-25 01:44:29
问题 I am trying to set up method level security via annotations for my Jersey managed REST webservice. I added a @PreAuthorize("hasRole('USER')") annotation to my web service interface where I define the endpoints. I have added a security configuration class, and a security initializer class to no avail. Username and password has been redacted. @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true, proxyTargetClass = true) @EnableWebSecurity public class SecurityConfiguration extends