jersey

405 error code while calling from Jersey REST client

自作多情 提交于 2019-12-10 16:26:48
问题 I am requesting for put operation and after request performed I am redirecting to GET service URL.Here, I am facing the issue of 405 HTTP error code. However, same code works for me in the case of POST operation. Below code is EndPoint: @PUT @Produces({ MediaType.APPLICATION_JSON }) public Response put(InputStream objInputStream) { // System.out.println("AckService.put()"); String strOutput = ""; Status objStatus = Status.OK; URI objRedirectionURI = null; try { this.submitRequest

Rest service throws exception : Best way to handle

旧城冷巷雨未停 提交于 2019-12-10 16:01:54
问题 I have a rest service which will throw an exception and I want to know what will be the best way to handle this. So I have a rest service which can throw a userdefined exception and I am catching that inside the catch block and throwing that exception again ! and using rest framework to catch that. Similarly for non-user defined exceptions. I thought this will be good as I have number of rest services and all userdefinedexception code handling will be at a same place. I would like to know is

Use ContainerRequestFilter in Jersey without web.xml

怎甘沉沦 提交于 2019-12-10 15:59:18
问题 I am trying to intercept requests in Jersey running inside Glassfish. I created an implementation of ContainerRequestFilter package mycustom.api.rest.security; @Provider public class SecurityProvider implements ContainerRequestFilter { @Override public ContainerRequest filter(ContainerRequest request) { return request; } } My app is started using a subclass of PackagesResourceConfig . When Glassfish starts, Jerseys find my provider: INFO: Provider classes found: class mycustom.rest.security

Dropwizard + Jersey : “Not inside a request scope” when creating custom annotation

吃可爱长大的小学妹 提交于 2019-12-10 15:54:27
问题 I have a simple Dropwizard 0.8.1 REST service that pulls in Jersey 2.17. Upstream of the REST/Jetty service I have some authentication service that adds some nice authorization information to the HTTP Header that gets passed to my Dropwizard app. I would love to be able to create a custom annotation in my Resource that hides all the messy header-parsing-to-POJO garbage. Something like this: @Path("/v1/task") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public

Cannot have JSP page load with Jersey server

半腔热情 提交于 2019-12-10 15:40:00
问题 I am using jersey 2.4 for my web service and cannot have the home page load the index.jsp. I made a IndexService POJO to try loading it from there too, but that doesn't work. I would like to just use the home page, instead of the having an IndexService POJO. The POJO is reached but returns this: HTTP Status 500 - org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=text/html, type=class org.glassfish.jersey.server.mvc.Viewable,

Jersey Server-Sent Events - write to broken connection does not throw exception

时间秒杀一切 提交于 2019-12-10 15:24:28
问题 We are using Jersey Server-Sent Events (SSE) to allow remote components of our application to listen to events raised by our Jersey/Tomcat server. This works great. However, it is crucial that our server have an accurate list of currently-connected listeners (our remote components). To this end, our server sends a tiny message to each caller (via eventOutput.write) once every five seconds. If our remote component is shut down while SSE-connected, or if the remote computer is powered off while

Jersey is not following 302 redirects

南楼画角 提交于 2019-12-10 15:21:58
问题 I am connecting to a server which first goes to an auth login page and then redirects. ClientConfig config = new DefaultClientConfig(); config.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true); Client client = Client.create(config); client.setFollowRedirects(true); WebResource service = client.resource(UriBuilder.fromUri(url).build()); String output = service.path(resource) .path(model) .path(id) .accept(MediaType.APPLICATION_JSON) .get(String.class); This is throwing an

Disable automatic Wadl Generation for OPTIONS request

邮差的信 提交于 2019-12-10 15:03:24
问题 I'm having trouble disabling automatic Wadl Generation in Jersey every time an OPTIONS request is received. I've tried adding the following to the servlet configuration in web.xml but it doesn't work: <init-param> <param-name>jersey.config.server.wadl.disableWadl</param-name> <param-value>true</param-value> </init-param> Can anyone help? 回答1: Just ran into this problem myself and it looks like you need to make sure the capitalization is correct for it to work: com.sun.jersey.config.feature

Jersey Joda Time ISO 8601 parameter in urlencoded form

限于喜欢 提交于 2019-12-10 14:56:34
问题 I am using Jersey: 1.17.1 and defined a REST service accepting "application/x-www-form-urlencoded". I would like to accept a parameter "b" in ISO-8601 format and let Jersey map this to a Joda DateTime. @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response createTask(@FormParam("a") String a, @FormParam("b") DateTime b) { ... but I am getting this exception SEVERE: The following errors and warnings have been detected with resource and/or

jersey/tomcat Description The origin server did not find a current representation for the target resource

北慕城南 提交于 2019-12-10 14:51:36
问题 I have configured jersey (with tomcat server) according to the details described until step 6.3 here: http://www.vogella.com/tutorials/REST/article.html#jerseyprojectsetup Below is my web.xml file, the only difference is that the path/package name for the jersey.config.server.provider.packages the instructions has; <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.vogella.jersey.first</param-value> because com.vogella.jersey.first is their package name, while I