jersey-2.0

Jersey Async ContainerRequestFilter

点点圈 提交于 2019-11-27 18:15:10
问题 I have a Jersey REST API and am using a ContainerRequestFilter to handle authorization. I'm also using @ManagedAsync on all endpoints so that my API can serve thousands of concurrent requests. My authorization filter hits a remote service, but when the filter is run, Jersey hasn't yet added the current thread to it's internal ExecutorService , so I'm completely losing the async benefits. Can I tell Jersey that I want this ContainerRequestFilter to be asynchronous? @Priority(Priorities

Can I change the property path in a ConstraintValidator for Method arguments?

社会主义新天地 提交于 2019-11-27 17:16:47
问题 If you are familiar with the Bean Validation Framework you know that you cannot get the name of a method argument. So if you do a @NotNull constraint on the first argument of a method and the validation fails the getPropertyPath will be something like "arg1". I would like to create my own version of @NotNull that can take a value e.g. @NamedNotNull( "emailAddress" ). But I can't figure out how to override the #getPropertyPath in my Validator? Is there any way to do this or am I stuck with

What is the moxy equivalent to Jackson's JsonAnySetter?

坚强是说给别人听的谎言 提交于 2019-11-27 16:59:17
问题 I'm attempting to move to Jersey 2.0. Which is giving me pains with Jackson, and the docs recommend using Moxy. I got Moxy working for get and post calls where everything matches nicely however I have a need to deal with possible unknown elements. // Handle unknown deserialization parameters @JsonAnySetter protected void handleUnknown(String key, Object value) { if (unknownParameters == null) { unknownParameters = new HashMap<>(); } unknownParameters.put(key, value); } This worked well with

Swagger documentation with JAX-RS Jersey 2 and Grizzly

假如想象 提交于 2019-11-27 16:17:19
I have implementated a Rest web service (the function is not relevant) using JAX-RS. Now I want to generate its documentation using Swagger. I have followed these steps: 1) In build.gradle I get all the dependencies I need: compile 'org.glassfish.jersey.media:jersey-media-moxy:2.13' 2) I documentate my code with Swagger annotations 3) I hook up Swagger in my Application subclass: public class ApplicationConfig extends ResourceConfig { /** * Main constructor * @param addressBook a provided address book */ public ApplicationConfig(final AddressBook addressBook) { register(AddressBookService

Why would “java.lang.IllegalStateException: The resource configuration is not modifiable in this context.” appear deploying Jersey app?

♀尐吖头ヾ 提交于 2019-11-27 16:01:16
I have created an app implementing REST services locally using: Eclipse Indigo Jersey 2.4 Tomcat 7.0.47 When running locally using Eclipse, the services work OK, but when deploying my WAR file, I get the following exception when trying to do a GET to one of the services URL: HTTP Status 500 - Servlet.init() for servlet com.app.rest.MyResourceConfig threw exception type Exception report message Servlet.init() for servlet com.app.rest.MyResourceConfig threw exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet

Spring-Jersey : How to return static content?

可紊 提交于 2019-11-27 15:50:41
Question : How do I expose my css/ , images/ , js/ and other static files? How do I return a JSP page in my controller (not a String method) for my index view? Problems : In efforts to solve question #1 other projects use a filter jersey.config.servlet.filter.staticContentRegex (as seen here Stackoverflow Question ) I haven't been able to find dependencies that work correctly/at all with my project setup. In efforts to solve question #2 I attempted to introduce dependencies to use Viewable . Problem - transitive dependencies adversely affect the webapp from using the appropriate classes for

Spring boot not serving static content when Jersey REST is included

和自甴很熟 提交于 2019-11-27 15:14:37
I am getting a HTTP 404 error when trying to serve index.html ( located under main/resources/static) from a spring boot app. However if I remove the Jersey based JAX-RS class from the project, then http://localhost:8080/index.html works fine. The following is main class @SpringBootApplication public class BootWebApplication { public static void main(String[] args) { SpringApplication.run(BootWebApplication.class, args); } } I am not sure if I am missing something here. Thanks Paul Samsotha The problem is the default setting of the Jersey servlet path, which defaults to /* . This hogs up all

How to access Jersey resource secured by @RolesAllowed

不问归期 提交于 2019-11-27 14:26:16
问题 We were testing a REST webservice developed in jersey through postman rest client. It is a POST method and is annotated with @RolesAllowed . The full annotation the method is as follows: @POST @Path("/configuration") @RolesAllowed("admin") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) When I requested this http://baseurl/configuration with the expected HTTP body content, I got 403 response(it is expected since it is allowed only for admin as it seems). My doubt

Jersey RESTful web service gradle setup

让人想犯罪 __ 提交于 2019-11-27 13:59:32
I am stuck with creating a gradle project for a RESTful web service using the jersey library. The project configuration should be capable of launching the service inside a jetty application server. I already found a resource: https://github.com/ziroby/jetty-gradle-hello-world My problem with that solution is, that it uses an outdated version of jersey. I need at least version 2(preferred latest 2.14). I tried to search for new versions on maven central, but in version 2 a lot of artifact names changed, and I am not able to configure it correctly. Edit: I do not specifically need a jetty server

Uploading file using Jersey over RESTfull service and The resource configuration is not modifiable?

家住魔仙堡 提交于 2019-11-27 10:17:52
问题 @Path("file.upload") public class UploadFileService { @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadFile( @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail) { System.out.println("-----------------UploadFileService------------------1."); // Should we use a disk or DB? Decided to use DISK // Path should be read from properties-files String uploadedFileLocation = "//uploaded/" + fileDetail.getFileName(); //