jersey

Glassfish @RolesAllowed with custom SecurityContext

柔情痞子 提交于 2019-12-09 04:57:41
问题 The question i'm about to ask is a bit tricky and I haven't found any answer yet. Maybe because i'm looking for the wrong thing. But i hope you will help me on this. I used the following tutorial to implement a custom SecurityContext that uses tokens instead of basic user/password authentication. Basically it initializes and injects a ResourceFilterFactory that will itself inject a ResourceFilter at every HTTP request sent to the application. This ResourceFilter searches for the

Unmarshalling LocalDate/LocalDateTime with MOXy

三世轮回 提交于 2019-12-09 03:58:51
问题 How can I get MOXy to unmarshal JSON into LocalDate and LocalDateTime ? I've got an @GET method which produces a sample instance with three fields of types LocalDate , LocalDateTime and Date , respectively. Hitting that endpoint, I get: { "localDate": "2017-07-11", "localDateTime": "2017-07-11T10:11:10.817", "date": "2017-07-11T10:11:10.817+02:00" } I then POST the above data to my @POST method, which simply returns the data again: { "date": "2017-07-11T10:11:10.817+02:00" } As you can see,

Jersey method selection by query parameters

我们两清 提交于 2019-12-09 03:46:30
问题 I need to implement a webservice that uses the first query parameter to identify the operation, i.e. the client call would be something like: http://localhost:8080/ws/operation?info or http://localhost:8080/ws/operation?create&name=something . It seems that I cannot distinguish the methods using the @Path annotation as the distinguishing characteristic is in the query parameters. And the following example is throwing exceptions as well: package com.example.ws; import javax.ws.rs.GET; import

Configuring Jersey + Jetty + JSP

纵饮孤独 提交于 2019-12-08 23:05:48
How do I configure this project so that it will be able to render JSP files? I would want to have URLS starting with /rest to route to jersey resources and have /* URLS serve JSP files. I don't have any web.xml in this project. Project folder ├───src │ └───main │ └───java/Main.java │ └───resources/HelloResource.java └───WEB-INF └───jsp/NewFile.jsp HelloResource.java package resources; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/hello") public class HelloResource { @GET @Produces("text/plain") public String handleGreeting() { return "Hello World"; }

Can I use Spring's MockMvc with Jersey resources?

假装没事ソ 提交于 2019-12-08 21:38:45
问题 I have successfully integrated Spring and Jersey via Spring Boot' starter POMs, and I have a couple Jersey endpoints. Now I'd like to unit test the resources. I can't seem to get MockMvc working. I get a 404 error when attempting to GET a resource endpoint. I know there is a Jersey test framework out there, but it appears to launch a server. I'm hoping to avoid "integration" type tests and keep this as simple as possible. Can I do this with MockMvc? 回答1: Unfortunately doesn't seem to be

What does context annotation do in Spring?

点点圈 提交于 2019-12-08 18:58:11
问题 In Rest API design, I am wondering what the exact purpose of the context annotation is? private HttpServletRequest request; @Context public void setRequest(final HttpServletRequest req) { request = req; } 回答1: The purpose is to indicate that the request property should be set from the context. @Context is used to inject various HTTP-ish contextual data, from here: In general @Context can be used to obtain contextual Java types related to the request or response. API docs (Not horribly useful

Scala type (inference) issue?

亡梦爱人 提交于 2019-12-08 18:53:29
问题 I'm developing a REST webservice in Scala using the Jersey JAX-RS reference implementation and I'm getting a strange error. I'm trying to create a ContentDisposition object using the ContentDisposition.ContentDispositionBuilder. ContentDisposition.ContentDispositionBuilder has two types T extends ContentDisposition.ContentDispositionBuilder and V extends ContentDisposition . The method type of ContentDisposition returns a builder instance. The code val contentDisposition = ContentDisposition.

Grizzly + Jersey Listening ONLY on Localhost

久未见 提交于 2019-12-08 18:46:52
问题 I'm using Jersey with an embedded version of Grizzly and I'd like to bind/listen on localhost ONLY. I'm creating the ThreadSelector using the GrizzlyWebContainerFactory with the create call: threadSelector = GrizzlyWebContainerFactory.create("http://127.0.0.1:8080/", initParams); This works, but I'm still able to hit the server from an external machine. How can I get it to bind to/listen on ONLY localhost? This is for configuration stuff, so I don't want anything off box to be able to connect

Java Jersey Rest : No provider classes found. (404 error when accessing URL)

佐手、 提交于 2019-12-08 17:45:00
问题 Edit: I hadn't realized that all request were first going into "Apache" and then were redirected to Tomcat. I added a new redirection in the apache2.conf file. See the accepted answer for details. I am having the exact same problem as this question. Jersey REST The ResourceConfig instance does not contain any root resource classes However the user never answered the question. I am using Tomcat, without maven. I followed this tutorial. http://www.ibm.com/developerworks/web/library/wa-aj-tomcat

Jersey: @PathParam with commas to List<MyObject>

*爱你&永不变心* 提交于 2019-12-08 17:09:55
问题 I would like to call my Webservice with this pattern : /resource/1,2,3 And in my Class I want to bind my parameters to a List of Object @Path("/resource") public class AppWS { @GET @Path("/{params}") public Response get(@PathParam("params") List<MyObject> params) { return Response.status(200).entity("output").build(); } } With a simple Object: public class MyObject { Integer value; public MyObject(Integer value) { this.value = value; } } nb: If it possible I don't want to create an