jersey-2.0

HK2 is not injecting the HttpServletRequest with jersey

不打扰是莪最后的温柔 提交于 2019-11-26 11:39:12
问题 I am trying to follow the example located here to create a factory in order to inject my HttpSession. Unfortunately no matter what I try it is not working. Not sure what could be the issue. I have tried injecting just the HttpServletRequest and a provider. Here is my example using a provider. The error is a null pointer exception when trying to access the provider in the provide method. If I try to inject the HttpServletRequest I get no object available for injection. I am running this inside

How to return a JSON object from a HashMap with Moxy and Jersey

不问归期 提交于 2019-11-26 11:33:46
问题 I am using Jersey 2.17 with Moxy and I have functions like : @Produces(APPLICATION_JSON) @Restricted public List<User> getFriends( @PathParam(\"user\") String user ) { return userDAO.getFriends(user); } User.preferences is a HashMap . It works fine for almost all Objects except for a HashMap which gets translated into: \"preferences\":{\"entry\":[{\"key\":{\"type\":\"string\",\"value\":\"language\"},\"value\":{\"type\":\"string\",\"value\":\"en\"}},{\"key\":{\"type\":\"string\",\"value\":\

java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

穿精又带淫゛_ 提交于 2019-11-26 10:27:20
I am trying to build a simple hello world application for two days using Jersey + Google app engine. For simple AppEngine project I followed these tutorials and both works just fine https://developers.google.com/appengine/docs/java/gettingstarted/creating https://developers.google.com/appengine/docs/java/webtoolsplatform But now I am trying to add Jersey and following this tutorial http://www.vogella.com/articles/REST/article.html . But server keeps giving me java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer when I add these lines in web.xml : <?xml

How do I properly configure an EntityManager in a jersey / hk2 application?

女生的网名这么多〃 提交于 2019-11-26 09:57:18
问题 I have a jersey-2 / hk2 application which uses JPA persistence. The EntityManager is bound at startup like this public MyApplication() { // ... register(new AbstractBinder() { @Override public void configure() { bindFactory(EmFactory.class) .to(EntityManager.class) .in(RequestScoped.class); } }); } with the factory class being public class EmFactory implements Factory<EntityManager> { private static final String PERSISTENCE_UNIT = \"unit\"; private EntityManagerFactory emf; private

How to in-memory unit test Spring-Jersey

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 07:39:45
问题 I\'m working with Spring-Jersey3 and cannot figure out how to unit test the RESTFul API with Spring beans Controller package com.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.service.DataSource; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path(\"test\") @Component public class SpringController { @Autowired private DataSource datasource;

Jersey 2.x Custom Injection Annotation With Attributes

非 Y 不嫁゛ 提交于 2019-11-26 07:39:29
问题 I am in the process of migrating from DropWizard 0.7.1 to 0.8.1. This includes migrating from Jersey 1.x to 2.x. In my implementation that uses Jersey 1.18.1, I had a MyProvider (changed all class names for simplicity\'s sake) that implements InjectableProvider . This class would create MyInjectable objects, containing the custom injection annotation, MyToken . MyToken contains various attributes that are passed on and read by MyInjectable . Lastly, in the Application class I register a new

NoSuchMethodError on startup in Java Jersey app

北城以北 提交于 2019-11-26 07:35:28
问题 I\'ve been getting a very strange error when trying to start a Jersey app on Tomcat. The same code works on other computers. I tried reinstalling tomcat, all my maven dependencies, even Eclipse and Java itself, no luck. It seems like a bad Jersey version is being loaded, I think? Any pointers in the right direction will be appreciated. Here\'s the effective pom: http://pastebin.com/NacsWTjz And the actual pom: http://pastebin.com/H6sHe4ce 2015-02-13 13:43:40,870 [localhost-startStop-1] ERROR

Listing all deployed rest endpoints (spring-boot, jersey)

时光总嘲笑我的痴心妄想 提交于 2019-11-26 07:34:28
问题 Is it possible to list all my configured rest-endpoints with spring boot? The actuator lists all existing paths on startup, I want something similar for my custom services, so I can check on startup if all paths are configured correctly and use this info for client calls. How do I do this? I use @Path / @GET annotations on my service beans and register them via ResourceConfig#registerClasses . Is there a way to query the Config for all Paths? Update: I register the REST Controllers via @Bean

Jersey stopped working with InjectionManagerFactory not found

喜夏-厌秋 提交于 2019-11-26 07:27:52
问题 I am receiving below error while running my Jersey API in Tomcat 8.5.11 which is causing my API to stop: HTTP Status 500 - Servlet.init() for servlet Jersey REST Service threw exception type Exception report message Servlet.init() for servlet Jersey REST Service threw exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet.init() for servlet Jersey REST Service threw exception org.apache

Jersey returns 404 with any error status code?

纵饮孤独 提交于 2019-11-26 06:49:27
问题 I have this useless endpoint in path \"/test\": @PUT public Response doSomething() { return Response.status(409).build(); } and I test it this way: @Test public void uselessTest() { put(\"/test\").then().assertThat().statusCode(409); } But I get an assertion error: Expected status code <409> doesn\'t match actual status code <404>. This happens in more codes: 400, 500... apart from 200. I\'m using Spring Boot. If I put a breakpoint in my endpoint method when I run the test, execution stops