jersey

Jersey REST API: java.lang.NoSuchMethodError: org.glassfish.jersey.message.filtering.EntityFilteringFeature.enabled

ぐ巨炮叔叔 提交于 2019-12-07 19:29:53
问题 in REST API using jersey, using Maven. Maven successfully added mox and entity jars. I'm getting below error when trying to get JSON type result. @Produces(MediaType.APPLICATION_JSON) content of pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>in.alonebirddev.acs</groupId> <artifactId

How can I put a cookie in Jersey RESTful webservice?

只愿长相守 提交于 2019-12-07 19:28:26
问题 I would like to put a cookie from "PUT webservice result" to "POST webservice" by Jersey API. Here is my code WebResource service1 = client.resource("http://test.com"); ClientResponse logResponse = service1.accept(MediaType.APPLICATION_XML).put(ClientResponse.class, "<?xml version='1.0'?><test>1</test>"); WebResource service2 = client.resource("http://test.com/post"); WebResource.Builder builder = service2.getRequestBuilder(); for(Cookie c : logResponse.getCookies()) { if(c.getName().equals(

JAX-RS Jersey/Grizzly Define an interface resource

拟墨画扇 提交于 2019-12-07 19:25:32
Following the example here On deploying a sample resource using the Grizzly container. It uses a resource that is defined as a class, instead I would like to define an interface with the annotations and have the resource class implements that interface. The problem now is that Grizzly complains that it can't find the resource: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes. On Main class, where "com.mycompany.pack" is the package containing the implementation class: final String baseUri = "http://localhost:9999/"; final

Java/Jersey - creating own injection resolver with ParamInjectionResolver - strange behavior

笑着哭i 提交于 2019-12-07 18:58:22
问题 I am trying to create an injection resolver. I have a data class: public class MyData { ... } I have the following annotation: @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface MyDataInject { } My injection resolver looks like this: public class MyDataInjectionResolver extends ParamInjectionResolver<MyDataInject> { public MyDataInjectionResolver () { super(MyDataValueFactoryProvider.class); } @Singleton public static class

How to integrate swagger with jersey + spring-boot

旧巷老猫 提交于 2019-12-07 18:08:45
问题 I am using springboot + jersey for web restful implementation. Now I am going to integrate swagger into our application. I did following. @Configuration @EnableSwagger2 public class JerseyConfiguration extends ResourceConfig { public JerseyConfiguration(){ register(HelloworldAPI.class); configureSwagger(); } private void configureSwagger() { BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.2"); beanConfig.setSchemes(new String[]{"http"}); beanConfig.setHost("localhost:8080

Jersey + Guice can't mix non-jersey resources with jersey resources

微笑、不失礼 提交于 2019-12-07 17:22:17
问题 How can I use non-jersey resources with jersey resources with guice ? I want "/" to be handled by a plain servlet. But I want "/users" handled by jersey. Say I have a jersey resource with @Path("/users"). Using the following bindings will not work, it tries to map the "/" request using jersey which of course is not a jersey resource and I get 404. protected void configureServlets() { serve("/").with(LoginServlet.class); serve("/*").with(GuiceContainer.class, params); } All of the examples of

Accepting a List as a parameter to a Jersey webservice that consumes a content type of multi-part

99封情书 提交于 2019-12-07 17:17:11
问题 I had an existing Jersey webservice method that accepts a number of parameters via Http POST method which is designed to handle a standard form data, content type of application/x-www-form-urlencoded; one of these parameters was a list of Strings. Below is an example of the method signature I have. @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response createItem( @FormParam("p1") long p1, @FormParam("p2") String p2, @FormParam("p3") List<String> p3, @FormParam("p4") String p4

Jersey: Pass value from ContainerRequestFilter to endpoint

╄→尐↘猪︶ㄣ 提交于 2019-12-07 17:14:06
问题 I am using Jersey 2.9 and I have created a filter which will take an encrypted header value, and decipher it and then pass it along to the endpoint which was called on. I have no idea of how to do this, and I have been searching on the internet but not really found a concrete example of what I want to do. The filter is called, I just have issues passing a value from it to the endpoint. Could you guys help me! Here is some sample code: public class MyFilter implements ContainerRequestFilter {

How can I get my hands on client addresses for logging using Grizzly / Jersey?

家住魔仙堡 提交于 2019-12-07 15:17:07
问题 I'm using Grizzly to serve a Jersey application, while using Logback for my logging needs. Please not that there are no Servlet s involved here, I fire up everything "by hand" using a piece of code like this: final URI uri = /* this is a configuration option */ this.server = new HttpServer(); final NetworkListener nl = new NetworkListener( "grizzly", uri.getHost(), uri.getPort()); server.addListener(nl); final GuiceComponentProviderFactory gcpf = new GuiceComponentProviderFactory(rc, inj);

What is the correct way to configure custom mapper for WebApplicationException?

让人想犯罪 __ 提交于 2019-12-07 14:47:59
问题 I've created class that implements implements ExceptionMapper<WebApplicationException> and registered it by environment.addProvider(new WebApplicationExceptionMapper()); . My custom mapper works but only for some exceptions extended from WebApplicationException . For example it doesn't work for ConflictException and it also doesn't work for my custom exceptions with following constructor: public ConflictException(URI location, Object entity) { super(Response.status(Response.Status.CONFLICT)