jersey-2.0

JSON not generated in using Jersey

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:50:37
问题 I'm using the latest version of Jersey to implement some REST sample services. Do you have any clue why when I generate the following HTTP request using Fiddler,I get: 500 Internal Server Error MessageBodyWriter not found for media type={application/json, q=1000}, type=class java.util.ArrayList, genericType=java.util.ArrayList<com.example.Todo> HTTP request: GET http://localhost:8080/RestProject/rest/todos/1 HTTP/1.1 Connection: close Accept: application/json User-Agent: Mozilla/5.0 (Windows

How to apply interceptors and filters to restful services on Weblogic 12c

徘徊边缘 提交于 2019-12-11 02:48:26
问题 I understand that Weblogic 12c v12.2.1 uses Jersey as a JAX-RS implementation. So I followed the instructions on this page but I haven't succeeded to declare an interceptor whether by using name binding or dynamic binding (i.e. more info in the mentioned link) My application is working normally because I can actually call the restful services, but I can't apply filters or interceptors, they are never involved in the process. I didn't edit web.xml at all, all I have is an javax.ws.rs.core

Spring Boot with Jersey and Spring Security OAuth2

牧云@^-^@ 提交于 2019-12-11 02:35:45
问题 Following the sample from Spring Boot: example code from GitHub everything seems to work fine. But when I integrate Spring Boot Security OAuth2 in the project, my OAuth2 endpoints stop working. There's a warning in the logs: 2017-05-04 08:56:24.109 WARN 2827 --- [nio-8080-exec-1] o.glassfish.jersey.servlet.WebComponent : A servlet request to the URI http://127.0.0.1:8080/oauth/token contains form parameters in the request body but the request body has been consumed by the servlet or a servlet

Getting 404 trying to render a JSP from Jersey 2

孤街醉人 提交于 2019-12-11 00:42:29
问题 I'm trying to make a simple example of a web application using Jersey 2 and JSP, and to deploy it on Glassfish 4. However, I keep getting 404 errors trying to access my only resource. First, the project structure: Here are the important classes and files: web.xml I'm setting Jersey as a filter, instead of a servlet, because I read it needs to be defined that way in order to make it work with JSP. <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org

How do i send a POST request without Transfer Encoding:chunked from Jersey ReST Client 2.22.2

99封情书 提交于 2019-12-10 23:27:30
问题 When i send a POST request through Jersey ReST client it's automatically using Header transfer-encoding: [chunked] . Is there any way to force use of content-length: instead of transfer-encoding.? WebTarget webTarget = client.target(connection.getServerUrl()); Invocation.Builder builder = webTarget.request(MediaType.APPLICATION_XML); Response response = builder.post(Entity.xml(requestBroker)); After adding Content-Length property too the behavior is same WebTarget webTarget = client.target

JSONP with Jquery 1.9 and Jersey 2.5.1

无人久伴 提交于 2019-12-10 23:19:44
问题 I've googled a lot and found nothing that suits my needs. I found these similar threads here, here and here, but they don't solve my problem or I don't understand this correctly. I also read the jersey documentation a couple of times. I'm developing a server side application with jersey 2.5.1 and the client side with HTML/CSS/JavaScript. So for this worked out great, but no I'm stumbling. I'm using Media-Moxy as my Java2Json mapper. @GET @JSONP @Path("search") @Produces({MediaType.APPLICATION

Jersey gives runtime error java.lang.NoClassDefFoundError: org/glassfish/jersey/server/ResourceConfig

为君一笑 提交于 2019-12-10 22:47:44
问题 I have defined jersey service as: private static HttpServer createHttpServer() throws IOException { final ResourceConfig resourceConfig = new ResourceConfig(Api.class); return JdkHttpServerFactory.createHttpServer(URI, resourceConfig); } This compiles fine. But when I try to run it it throws java.lang.NoClassDefFoundError : Exception in thread "main" java.lang.NoClassDefFoundError: org/glassfish/jersey/server/ResourceConfig at EmbeddedHTTPServer.createHttpServer(Unknown Source) at

How to access wicket session from Jersey-2 request filter?

一曲冷凌霜 提交于 2019-12-10 20:39:47
问题 In Jersey 1.x we accessed the Wicket session from a (Jersey) session attribute, as described here https://stackoverflow.com/a/15767824/1399659. In moving to Jersey 2.x it seems the proper pattern to use a ContainerRequestFilter, which also allows Spring bean injection as well. We have this working successfully by including <param-name>jersey.config.server.provider.packages</param-name> as an init-param to the ServletContainer and using the @Provider annotation on a ContainerRequestFilter

Jersey - Register ExceptionMapper for Resource Methods

时间秒杀一切 提交于 2019-12-10 19:48:43
问题 The question Exception Handling/Mapping for a particular class brought me to the question of how to register an ExceptionMapper to a particular resource Method . I've tried to use a DynamicFeature like this: DynamicFeature @Provider public class ExceptionMapperDynamicFeature implements DynamicFeature { @Override public void configure(final ResourceInfo resourceInfo, final FeatureContext context) { if(!resourceInfo.getResourceMethod().isAnnotationPresent(BindExceptionMapper.class)) return;

Jackson JsonDeserialize not being called for @QueryParam

我的未来我决定 提交于 2019-12-10 19:30:25
问题 I have mapped a custom deserializer to convert Strings on dd/MM/yyyy pattern to LocalDate so I can call my services with a more readable signature.. This is my dto class that is used as a Jersey @BeanParam to transport data between layers: public class ProdutoFilterDto implements FilterDto { private static final long serialVersionUID = -4998167328470565406L; @QueryParam("dataInicial") @JsonDeserialize(using = CustomLocalDateDeserializer.class) private LocalDate dataInicial; @QueryParam(