jersey-2.0

Jersey REST Web Service with Tomcat, Eclipse and 404's - Need another set of eyes please

我只是一个虾纸丫 提交于 2019-12-11 12:55:31
问题 This should be so simple, but its blowing my mind... I have read through hundreds of the questions here, and so far none of the responses has made a difference in what I have tried. It is obviously time for another set of eyes.. I am getting a 404 error when trying to do the most simple of rest tests. My Tomcat 7.0 Servers starts up just fine. No errors. My project name in Eclipse is: atomic_services_poc The Context in Tomcat is set to: /atomic_services_poc I can successfully return static

Netbeans 8.1 and Jersey 2

假装没事ソ 提交于 2019-12-11 12:47:55
问题 I have the latest version of netbeans and I'm trying to run the DataAppClient Sample which comes with JavaFX SDK Samples, DataAppClient imports the following packages : com.sun.jersey.api.client.Client; com.sun.jersey.api.client.UniformInterfaceException; com.sun.jersey.api.client.WebResource; com.sun.jersey.api.json.JSONConfiguration; Netbeans shows an error sign on each of these packages says "package doesn't exist". it's clear that all these packages related to the Jersey, and all the

Generate REST API documentation

久未见 提交于 2019-12-11 12:38:45
问题 Is there a way to auto-generate a ZOHO-style documentation of my Jersey Rest Services? This is one of the best REST documentations I have seen so far. I'm open to alternatives. Swagger also looks promising but I don't see how to generate it. It seems like it needs a YAML style documentation. Can I generate it from javadoc somehow? I'd prefer to generate the docs via Maven. 回答1: Adding swagger to jersey based services is not too complicated. See these detailed steps on how to go about it: Hope

jax-rs share information between ContainerRequestFilter and ReaderInterceptor

你说的曾经没有我的故事 提交于 2019-12-11 11:55:15
问题 I'm using Jax-rs, and I'm doing some logic in the Filters , and then I would like to share information between ContainerRequestFilter (Filter) and ReaderInterceptor (Interceptor). I can see that between Filters and Interceptors is possible through the set/getProperties but between Filter and Interceptors is not possible. Any idea if there's any other mechanism?. Regards. 回答1: You can use a request scoped service that you inject into both the filter and the interceptor. For instance public

Handling MultiException of jersey

安稳与你 提交于 2019-12-11 11:53:45
问题 How can we handle the MultiException of jersey which contains a list of Throwable objects? The exception mapper technique works fine in the case of one exception, but how can I handle multiple exceptions? 回答1: You can get the list of exceptions by calling getErrors() on the MultiException. The method defined in MultiException class is: public List<Throwable> getErrors() { synchronized (this.lock) { return Collections.unmodifiableList(this.throwables); } } In your mapper you can use this list

How can I inject a custom factory using hk2?

青春壹個敷衍的年華 提交于 2019-12-11 11:01:42
问题 I'm having a hard time to work with jersey test framework. I have a root resource. @Path("sample") public class SampleResource { @GET @Path("path") @Produces({MediaType.TEXT_PLAIN}) public String readPath() { return String.valueOf(path); } @Inject private java.nio.file.Path path; } I prepared a factory providing the path . public class SamplePathFactory implements Factory<Path> { @Override public Path provide() { try { return Files.createTempDirectory(null); } catch (final IOException ioe) {

Spring boot runtime add controller?

吃可爱长大的小学妹 提交于 2019-12-11 10:37:19
问题 Is it possible for springboot/spring-mvc or Jersey to add controller (& methods) at runtime ? Meaning when running , user may input a controller name ( such as user ) , and method name sayHello , and submit , and /user/sayHello/ is enabled without restarting spring server ? (As to what to response , that's beyond the scope , just assume reply 'OK' ) If spring cannot achieve it , which JVM rest framework supports such functionality ? It seems jersey can Programmatically build API Resource ,

Jersey: How to register MultiPartConfigProvider class

杀马特。学长 韩版系。学妹 提交于 2019-12-11 09:43:28
问题 I'm trying to load multiple files with jersey, but it demands me some configuration that i can't find. This is the dependency, I had to add it because jersey couldn't resolver the type "multipart/related": <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-multipart</artifactId> <version>2.7</version> </dependency> This is the API where I use the multipart: @PUT @Consumes("multipart/related") @Path("/{id}/user/{userId}") public Response loadFile(@PathParam("id

Jersey Update Entity Property MessageBodyWriter

倖福魔咒の 提交于 2019-12-11 09:01:17
问题 I want to create a Jersey provider (MessageBodyWriter) that update a dto object property and continue the chain to Jersey-json default provider an return the json object. the problem is that looks like default provider is not called so the output of my rest service become empty as soon as I register the new Provider. @Provider public class TestProvider implements MessageBodyWriter<MyDTO> { @Override public long getSize( MyDTO arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4)

Is it possible to use Spring MVC with Jersey annotations?

落花浮王杯 提交于 2019-12-11 08:17:58
问题 I am wondering, if it's possible to use Spring Web MVC with Jersey annotations, as I'm having a massive problem with Spring not being able to parse part variables the way Jersey can and I need to migrate some Jersey code to Spring MVC. I have the following code in Jersey: @PUT @Path("{storageId}/{repositoryId}/{path:.*}") @PreAuthorize("hasAuthority('ARTIFACTS_DEPLOY')") public Response upload(@PathParam("storageId") String storageId, @PathParam("repositoryId") String repositoryId, @PathParam