jersey-2.0

NoSuchMethodError on startup in Java Jersey app

旧时模样 提交于 2019-11-26 20:24:44
I've been getting a very strange error when trying to start a Jersey app on Tomcat. The same code works on other computers. I tried reinstalling tomcat, all my maven dependencies, even Eclipse and Java itself, no luck. It seems like a bad Jersey version is being loaded, I think? Any pointers in the right direction will be appreciated. Here's the effective pom: http://pastebin.com/NacsWTjz And the actual pom: http://pastebin.com/H6sHe4ce 2015-02-13 13:43:40,870 [localhost-startStop-1] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/middleware-server] - StandardWrapper

Jersey returns 404 with any error status code?

孤街浪徒 提交于 2019-11-26 19:11:28
I have this useless endpoint in path "/test": @PUT public Response doSomething() { return Response.status(409).build(); } and I test it this way: @Test public void uselessTest() { put("/test").then().assertThat().statusCode(409); } But I get an assertion error: Expected status code <409> doesn't match actual status code <404>. This happens in more codes: 400, 500... apart from 200. I'm using Spring Boot. If I put a breakpoint in my endpoint method when I run the test, execution stops there, so the request in the test is done properly. If I change the status code (in resource and in the test,

Custom ObjectMapper with Jersey 2.2 and Jackson 2.1

冷暖自知 提交于 2019-11-26 18:39:10
I am struggling with a REST application with Grizzly, Jersey and Jackson, because Jersey ignores my custom ObjectMapper. POM dependencies: <dependencies> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-grizzly2-servlet</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> <version>2.1.4</version> </dependency> </dependencies> Resulting versions are: Grizzly 2.3.3, Jackson 2.1.4 and Jersey 2.2. Main class (I want explicit registration of

Jersey fails when creating uber jar with maven-assembly-plugin

人盡茶涼 提交于 2019-11-26 18:00:36
I have created a maven jersey starter webapp. Also I have embedded jetty server in my app using jetty plugin. My project is working fine when I run my project using mvn jetty:run command. But when I package my project using mvn clean package command and run the jar file which has name jar-with-dependencies the project throws this exception while returning a json response from a jersey resource. SEVERE: MessageBodyWriter not found for media type=application/json, type=class com.nitish.freecharge.model.Count, genericType=class com.nitish.freecharge.model.Count. Here is my pom.xml file http:/

Spring boot not serving static content when Jersey REST is included

三世轮回 提交于 2019-11-26 17:06:13
问题 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 回答1: The problem

Spring Boot + Jersey type filter - Bad request 400 for service Consumes MULTIPART_FORM_DATA

只谈情不闲聊 提交于 2019-11-26 14:53:48
问题 I'm using Spring boot v1.5.10 + Jersey v2.25.1, configured jersey as filter to access static folder files. I'm getting HTTP response 400 Bad Request for a service consuming MULTIPART_FORM_DATA . Props to configure Jersey as filter. spring.jersey.type=filter If I remove above property i.e., using Jersey as Servlet, the service is working, but I'm not able to access static folder. Here is the controller, @POST @Path("/save") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType

How to handle Spring Boot&#39;s redirection to /error?

浪子不回头ぞ 提交于 2019-11-26 14:52:19
问题 I've encountered the same issue as in this question, using Spring Boot 1.3.0 and not having my controllers annotated with @RestController , just @Path and @Service . As the OP in that question says, this is, to me, anything but sensible I also can't understand why would they have it redirect to /error. And it is very likely that I'm missing something , because I can only give back 404s or 200s to the client. My problem is that his solution doesn't seem to work with 1.3.0, so I have the

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

这一生的挚爱 提交于 2019-11-26 14:48:52
问题 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

How to inject an object into jersey request context?

纵然是瞬间 提交于 2019-11-26 14:39:23
I have this scenario where I want to write a filter and I want this filter to insert some object into the current request and pass it on so that when the resource class gets the request it can use the object. Filter class @Override public void filter(ContainerRequestContext request) throws IOException { MyObject obj = new MyObject(); // Inject MyObject to request which I dont know how } Resource Class @PUT @Consumes("application/json") @Path("/") public String create( JSONParam sample, @Context MyObject obj) { System.out.println(obj.getName()); return ""; } Paul Samsotha You could just use

Jersey ContainerRequestFilter not triggered

筅森魡賤 提交于 2019-11-26 13:48:54
问题 I'm trying to use a ContainerRequestFilter to enforce some authentication on a Tomcat based Jersey application. I followed this document. Problem : the filter is never triggered The filter class : @Provider public class AuthFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { // MY AUTHENTICATION CODE GOES HERE } The web.xml file : <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001