jersey-1.0

How to read JSON request body in Jersey

白昼怎懂夜的黑 提交于 2019-12-03 06:23:41
I have a requirement, where in i need to read JSON request that is coming in as part of the request and also convert it to POJO at the same time. I was able to convert it to POJO object. But I was not able to get the request body (payload) of the request. For Ex: Rest Resource will be as follows @Path("/portal") public class WebContentRestResource { @POST @Path("/authenticate") @Consumes(MediaType.APPLICATION_JSON) public Response doLogin(UserVO userVO) { // DO login // Return resposne return "DONE"; } } POJO as @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class UserVO {

How do I migrate from Jersey 1.0 to Jersey 2.0?

最后都变了- 提交于 2019-12-03 02:29:56
I'm trying to upgrade to Jersey 2.0 and I'm having a lot of trouble because the groupIds and artifactIds of Jersey have completely changed and I can't find a migration plan in the Jersey docs . Here's what my pom.xml used to look like, and this compiled fine: <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.17</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId> <version>1.17</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey

How can I generate documentation for my Jersey REST API that uses JSON JAXB binding?

我只是一个虾纸丫 提交于 2019-12-02 09:34:54
问题 Now that I've figured out how to use JAXB generate JSON I can request/respond with it on my server and I'd like to figure out how I can generate useful documentation for human beings that are not using Java. My server code looks like this: @POST @Path("apath") @Consumes(MediaType.APPLICATION_JSON) public String postAPath(InstanceWithXmlRootElementAnnotation instanceWithXmlRootElementAnnotation) { That's all well in good if someone is using Java. I just give them the Jar with the

Weblogic 12c : Prefer-web-inf-classes and prefer-application-packages for Jersey

不打扰是莪最后的温柔 提交于 2019-12-01 17:52:15
I have to use both (oddly enough ..) " prefer-web-inf-classes " and " prefer-application-packages properties of weblogic.xml on a Weblogic 12c Server (12.2.1) It is REST application based on Jersey 1.9. * ( Jersey 1.x JAX-RS RI) and Guice. 1. Why use :prefer-web-inf-classes If you have more than one WAR you have to place at the level of war/lib the libraries for guice-jersey / guice , other way you get an Multibindings Error . It must be indicate also the prefer-web-inf-classes to true . This way works properly! I have tried to work in the same way using prefer-application-packages with

Weblogic 12c : Prefer-web-inf-classes and prefer-application-packages for Jersey

给你一囗甜甜゛ 提交于 2019-12-01 15:53:03
问题 I have to use both (oddly enough ..) prefer-web-inf-classes and prefer-application-packages properties of weblogic.xml on a Weblogic 12c Server (12.2.1) It is REST application based on Jersey 1.9. ( Jersey 1.x JAX-RS RI) and Guice. 1. Why use :prefer-web-inf-classes If you have more than one WAR you have to place at the level of war/lib the libraries for guice-jersey / guice , other way you get an Multibindings Error. It must be indicated also the prefer-web-inf-classes to true . This way it

How to produce JSON output with Jersey 1.17.1 using JAXB

北城以北 提交于 2019-12-01 10:58:43
There is a correct answer to this question already on this site. The problem is that the question is for Jersey 1.6 and the correct answer for Jersey 1.17.1 is buried at the bottom. I figured I'd create a correct question for this answer so that it'd be easier to find help for people struggling with this (like I was). 11101101b First, you need to add this to your web.xml: <servlet> <servlet-name>JerseyServlet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> <param

Introspecting Jersey resource model Jersey 2.x

谁都会走 提交于 2019-11-29 07:28:13
I have written my own scanner to go through my JAX-RS resources and print out the method names and paths using jersey-server-1.18.1 . The problem is when I migrate my same code to 2.16 (changing the package names from com.sun.* to org.glassfish.* ), It just won't work. Digging deep I found that those required jersey-server classes are no long public. Anyone knows the reason why? And how can I migrate my code below from 1.x to 2.x ? There is literally no documentation on this migration. All help appreciated! Below is the code with 1.x import com.wordnik.swagger.annotations.ApiOperation; import

How to get resource method matched to URI before Jersey invokes it?

只愿长相守 提交于 2019-11-28 06:54:33
I'm trying to implement a ContainerRequestFilter that does custom validation of a request's parameters. I need to look up the resource method that will be matched to the URI so that I can scrape custom annotations from the method's parameters. Based on this answer I should be able to inject ExtendedUriInfo and then use it to match the method: public final class MyRequestFilter implements ContainerRequestFilter { @Context private ExtendedUriInfo uriInfo; @Override public ContainerRequest filter(ContainerRequest containerRequest) { System.out.println(uriInfo.getMatchedMethod()); return

Introspecting Jersey resource model Jersey 2.x

て烟熏妆下的殇ゞ 提交于 2019-11-28 01:05:44
问题 I have written my own scanner to go through my JAX-RS resources and print out the method names and paths using jersey-server-1.18.1 . The problem is when I migrate my same code to 2.16 (changing the package names from com.sun.* to org.glassfish.* ), It just won't work. Digging deep I found that those required jersey-server classes are no long public. Anyone knows the reason why? And how can I migrate my code below from 1.x to 2.x ? There is literally no documentation on this migration. All

How to force URIBuilder.path(…) to encode parameters like “%AD”? This method doesn't always encode parameters with percentage, correctly

一个人想着一个人 提交于 2019-11-27 23:33:45
How to force URIBuilder.path(...) to encode parameters like "%AD" ? The methods path , replacePath and segment of URIBuilder do not always encode parameters with percentage, correctly. When a parameter contains the character "%" followed by two characters that together form an URL-encoded character, the "%" is not encoded as "%25". For example URI uri = UriBuilder.fromUri("https://dummy.com").queryParam("param", "%AD"); String test = uri.build().toString(); "test" is " https://dummy.com?param=%AD " But it should be " https://dummy.com?param=%25AD " (with the character "%" encoded as "%25") The