jersey-2.0

404 error with Jersey REST Service on Tomcat

痞子三分冷 提交于 2019-12-01 07:35:19
问题 I have looked at all the answers available on this topic, either I am facing a completely different problem or I am missing something big time. Service Class: package org.test; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; //http://localhost:8080/JunkWeb/rest/TestRestService/callService @Path("/TestRestService") public class TestRestService { @GET @Path("/callService") @Produces(MediaType.TEXT_PLAIN) public String callService(

Registering a custom ValueParamProvider in Jersey 2.27

徘徊边缘 提交于 2019-12-01 07:35:09
问题 I realize that these are internal APIs, but if they're available internally why not make them usable by the less privileged masses, and they're also extremely useful. Even though these APIs were internal in Jersey 2.25 they could be used, and I'd like to upgrade my Jersey version without breaking my custom Jersey extensions. It's certainly possible to extend ValueParamProvider in Jersey 2.27, but I no longer see a way to register that Provider along with it's triggering annotation. Looking at

How to use Jersey with a newer version of jackson

ε祈祈猫儿з 提交于 2019-12-01 07:15:27
I am using Jersey (2.23.1) with jersey-media-json-jackson . But that is linked against Jackson 2.5.4. But I need to use Jackson 2.6.0 (or a newer version). How can I do this? I tried to set it in my pom.xml: <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-jsonSchema</artifactId> <version>2.6.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.6.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-xml-provider

Is there an Interceptor in Jersey similar to that of Spring's HandlerInterceptor

╄→尐↘猪︶ㄣ 提交于 2019-12-01 06:22:15
I need an Interceptor in Jersey 2.x which gives references to request, response and the Method which matched the Path to a Web Service. Something similar to HandlerInterceptor of Spring. Requirements: Need Annotations used on Class - Perform the below checks, Only if the corresponding Method which needs to be invoked by jersey is NOT Annotated with a custom annotation. Request - To get/set attributes and get Session Object to validate user. Response - To re-direct the call in case any validation fails even before invoking the corresponding Methos. Spring equivalent code: public class

Using a custom hk2 InjectionResolver to inject application configuration

只愿长相守 提交于 2019-12-01 06:06:43
Kind of a follow up to my previous question . I'm trying to inject application configuration data using JSR-330 standard annotations and the HK2 framework bundled with jersey. Ideally I'd like to create a custom InjectionResolver for the Named annotation, which will lookup the desired values in a Map or Properties object that I will populate from data read elsewhere. In my first attempt I've created an Application instance like public class MyApplication extends ResourceConfig { ... packages(MY_PACKAGES); property(MY_CONFIG_PROPERTY, someValue); register(new AbstractBinder() { @Override

Adding JAR with ObjectMapper makes my ObjectMapper non-discoverable

落花浮王杯 提交于 2019-12-01 05:46:31
How can I make my object mapper work in situation when there is another object mapper defined in jar from dependencies ? I'm trying to use Swagger with Jersey 2 which is being run under Jetty. The problem is that as soon as I add Swagger JAX-RX jar into classpath my object mapper is not discovered therefore I lose custom serialization of my objects. Here is how my object mapper defined @Provider public class ObjectMapperProvider implements ContextResolver<ObjectMapper> { } I've posted issue to Swagger's maintainers where you could read details. After hours of debugging in internals of Jersey I

ParamConverterProvider method return type mismatch

被刻印的时光 ゝ 提交于 2019-12-01 05:40:22
In the below code snippet I keep receiving the following error in the Provider class. Type mismatch: cannot convert from DemoParamConverter to ParamConverter package com.ofss.shop.application.translators; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import javax.ws.rs.ext.ParamConverter; import javax.ws.rs.ext.Provider; @Provider public class DemoParamConverterProvider { private final DemoParamConverter dpc = new DemoParamConverter(); public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { return dpc; } } package com

Is there an Interceptor in Jersey similar to that of Spring's HandlerInterceptor

。_饼干妹妹 提交于 2019-12-01 05:29:20
问题 I need an Interceptor in Jersey 2.x which gives references to request, response and the Method which matched the Path to a Web Service. Something similar to HandlerInterceptor of Spring. Requirements: Need Annotations used on Class - Perform the below checks, Only if the corresponding Method which needs to be invoked by jersey is NOT Annotated with a custom annotation. Request - To get/set attributes and get Session Object to validate user. Response - To re-direct the call in case any

Serialize Java 8 Stream with Jersey

拥有回忆 提交于 2019-12-01 05:14:26
How can I serialize a Java 8 java.util.Stream<T> with Jersey. I tried to write a MessageBodyWriter , but I need to know how to compose (decorate) existing MessageBodyWriters with a new MessageBodyWriter for my Stream . Stream<String> get(){ return some stream of strings } public <T> class StreamMessageBodyWriter<Stream<T>> implements MessageBodyWriter<Stream<T>> { public void writeTo(.......){ //How can I get the handle to MessageBodyWriter that will write for type T, //so that I can 'collect' the 'java.util.Stream<T>' and write it to //OutputStream } } but I need to know how to compose

Using a custom hk2 InjectionResolver to inject application configuration

假装没事ソ 提交于 2019-12-01 03:56:56
问题 Kind of a follow up to my previous question. I'm trying to inject application configuration data using JSR-330 standard annotations and the HK2 framework bundled with jersey. Ideally I'd like to create a custom InjectionResolver for the Named annotation, which will lookup the desired values in a Map or Properties object that I will populate from data read elsewhere. In my first attempt I've created an Application instance like public class MyApplication extends ResourceConfig { ... packages