jersey-2.0

How to specify context path for jersey test with external provider

做~自己de王妃 提交于 2019-12-20 06:00:41
问题 I want my jersey tests to run on one instance of tomcat which has the rest services running at http://myhost:port/contexpath/service1/ http://myhost:port/contexpath/service2/ ..so on I have both in memory and external container dependencies [ group: 'org.glassfish.jersey.test-framework.providers', name: 'jersey-test-framework-provider-inmemory', version: '2.17'], [group: 'org.glassfish.jersey.test-framework.providers', name: 'jersey-test-framework-provider-external' , version: '2.17'], Then

Jersey and HK2 - Injecting current user

戏子无情 提交于 2019-12-20 03:19:27
问题 I'm working with jersey 2.17 and HK2 to create a simple rest app. I have a ContainerRequestFilter that rejects any request that doesn't have the "currentuser" cookie. I have something like this: @Path("/users") public class UserResource { private UserService userService; @GET @Path("/orders") @Produces("application/json") public List<Order> findOrdersOfCurrentUser() { // some ugly code to access headers, extract cookies, and finally // extract username (a String) from a particular cookie

@Immediate annotation use in Jersey2

十年热恋 提交于 2019-12-19 08:12:40
问题 I have a similar issue to the one raised here: How do I get my Jersey 2 Endpoints to eagerly initialize on startup? But slightly further down the line. I can get my resource immediately loaded, but when I try to use it by calling the REST url, I get the following stack trace. java.lang.IllegalStateException: Could not find an active context for org.glassfish.hk2.api.Immediate 2. java.lang.IllegalStateException: While attempting to create a service for SystemDescriptor( implementation=com

Multipart upload to appengine

好久不见. 提交于 2019-12-19 05:00:09
问题 I'm having multiple problems with appengine (java/jersey), but now I'm stucked with uploading files via multipart. I've read this answer: https://stackoverflow.com/a/31325201 It worked for localhost, but when I upload to appengine, it shows the same error when starting the server: java.lang.SecurityException: Unable to create temporary file Does anyone know why it can be? Thanks! 回答1: You have to use Blobstore for uploading. Call blobstoreService.createUploadUrl to create an upload URL for

how to disable Jersey from weblogic 12.2.1

拜拜、爱过 提交于 2019-12-19 03:48:04
问题 Weblogic 12.2.1 has Jersey 2.21.1 inside as implementation of JAX-RS 2.0,but we would like to use Jersey 2.5.1 or Jersey of the latest version. General way to solve the conflict is to define classes in configuration file to load classes from application. But when you upgrade weblogic or Jersey, you have to look into the class conflict and make changes to configuration, is there a convenient way to disable Jersey from weblogic? 回答1: You need to include the jersey files in the web-inf lib of

Bean Validation 400 errors are returning default error page (html) instead of Response entity (json)

China☆狼群 提交于 2019-12-19 03:37:24
问题 I have a JUnit testsuite: GrizzlyHttpServerFactory + Jersey + Bean Validation (jersey-container-grizzly2-servlet/jersey-bean-validation ver 2.12, grizzly-http-server ver 2.3.16, hibernate-validator ver 5.0.0.Final) The 400 errors generated by a ValidationException are returning Grizzly's default error page (html) instead of the Bean Validation's Response entity (json). I've tried a ClientResponseFilter and its entityStream also contains the html error page. When I run the system under Tomcat,

Jersey 2.x does not support POJO to json?

a 夏天 提交于 2019-12-19 03:20:25
问题 While i am trying to convert java object to json object by using jersey.i am having an exception. Java code :-(POJO) package org.jersey.media.type; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class MyJaxbBean { public String name; public int age; public MyJaxbBean() {} // JAXB needs this public MyJaxbBean(String name, int age) { this.name = name; this.age = age; } } Resource :- package org.jersey.media.type; import javax.ws.rs.GET; import javax.ws.rs.Path; import

Why does jersey have no error log when the status is 500?

杀马特。学长 韩版系。学妹 提交于 2019-12-18 20:05:52
问题 This is my web.xml: <servlet> <servlet-name>Jersey REST Service</servlet-name> <servlet-class> org.glassfish.jersey.servlet.ServletContainer </servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>rest</param-value> </init-param> <init-param> <param-name>jersey.config.server.provider.classnames</param-name> <param-value>org.glassfish.jersey.filter.LoggingFilter</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> And

Why does jersey have no error log when the status is 500?

烂漫一生 提交于 2019-12-18 20:05:12
问题 This is my web.xml: <servlet> <servlet-name>Jersey REST Service</servlet-name> <servlet-class> org.glassfish.jersey.servlet.ServletContainer </servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>rest</param-value> </init-param> <init-param> <param-name>jersey.config.server.provider.classnames</param-name> <param-value>org.glassfish.jersey.filter.LoggingFilter</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> And

Jersey custom SecurityContext on EJB jax-rs resource

安稳与你 提交于 2019-12-18 17:11:54
问题 I am trying to implement my own ContainerRequestFilter and configure SecurityContext . It works well on jax-rs resources but EJB jax-rs throws javax.ejb.AccessLocalException Only relevant thing I found is 4 years old and the workaround doesn't seem pretty. https://java.net/projects/jersey/lists/users/archive/2010-05/message/265 My custom SecurityContext: @Provider @PreMatching public class SecurityFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext