jax-rs

which init-param to use: jersey.config.server.provider.packages or javax.ws.rs.Application?

半世苍凉 提交于 2019-12-29 11:38:28
问题 I am deploying JAX-RS web services to a Tomcat servlet container. I have seen code examples that use either of the following two methods of indicating the resources in the web.xml file: method 1 - using the `jersey.config.server.provider.packages` init-param <servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com

which init-param to use: jersey.config.server.provider.packages or javax.ws.rs.Application?

爷,独闯天下 提交于 2019-12-29 11:37:42
问题 I am deploying JAX-RS web services to a Tomcat servlet container. I have seen code examples that use either of the following two methods of indicating the resources in the web.xml file: method 1 - using the `jersey.config.server.provider.packages` init-param <servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com

Practical advice on using Jersey and Guice for RESTful service

牧云@^-^@ 提交于 2019-12-29 10:06:14
问题 From what I can find online, the state of the art for Guice + Jersey integration has stagnated since 2008 when it appears both teams reached an impasse. The crux of the issue is that JAX-RS annotations perform field and method injection and this doesn't play nicely with Guice's own dependency injection. A few examples which I've found don't go far enough to elucidate: Iqbalyusuf's post on Jersey + Guice on Google App Engine Java suffers from a lot of boilerplate (manually getting and calling

How to use Spring Boot 1.5.2 to inject implementations of Jersey endpoint interfaces?

倾然丶 夕夏残阳落幕 提交于 2019-12-29 09:27:28
问题 I am scaling back a large web application that included a web service to become only a Jersey web service, on Spring Boot 1.5.2. Because the web service already had a complete set of JAX-RS annotations implemented by Apache Wink, I decided to go with Spring + Jersey instead of Spring Rest. I found this spring-boot-jersey-sample application to use as a reference. The biggest difference between the application I'm working on and the sample is that my endpoint definitions are divided between

Missing Elements in HTTP Request - Null or Empty?

丶灬走出姿态 提交于 2019-12-29 07:47:07
问题 I have a HTTP Request javax.servlet.http.HttpServletRequest that is passing in a value to be used in some code being handled in a Java web service using JAX-RS. The POST function in Java is consuming application/json . There are two possible values to be passed into the request, call one X and the other Y , assume both are Strings. The request requires at least one of the two possible values to be considered 'valid'. When the request comes in, if X is provided and Y is left out of the request

Tomcat, JAX-RS, Jersey, @PathParam: how to pass dots and slashes?

风格不统一 提交于 2019-12-29 07:25:44
问题 Having a method like this: @GET @Path("/name/{name}") @Produces(MediaType.TEXT_PLAIN) public String getProperty(@PathParam("name") String name) { System.out.println(name); } How do I pass a value like "test./test"? /name/test./test gives HTTP 404 /name/test.%2Ftest gives HTTP 400 /name/test.%252Ftest prints test%2Ftest But if I do name = URLDecoder.decode(name); it prints /test and the first part of test. disappears. There is one or two questions like this already but they are old and there

How to catch RESTEasy Bean Validation Errors?

微笑、不失礼 提交于 2019-12-29 07:15:14
问题 I am developing a simple RESTFul service using JBoss-7.1 and RESTEasy. I have a REST Service, called CustomerService as follows: @Path(value="/customers") @ValidateRequest class CustomerService { @Path(value="/{id}") @GET @Produces(MediaType.APPLICATION_XML) public Customer getCustomer(@PathParam("id") @Min(value=1) Integer id) { Customer customer = null; try { customer = dao.getCustomer(id); } catch (Exception e) { e.printStackTrace(); } return customer; } } Here when I hit the url http:/

In REST / Java, what should I return if my object is null?

…衆ロ難τιáo~ 提交于 2019-12-29 06:24:53
问题 I have a simple POJO that I annotated with REST annotations as follows: @GET @Path("/domains/{domainid}") @Override public Domain getDomain(@PathParam("domainid") UUID domainID) throws Exception { logger.info("Retrieving domain "+ domainID); Domain d = null; try { d = MyClient.getDomains().get(domainID.toString()); logger.debug("Returning "+d.getName()); } catch (Exception e) { logger.error("Could not retrieve domain", e); } return d; } Note that the log statement including d.getName() can

In REST / Java, what should I return if my object is null?

会有一股神秘感。 提交于 2019-12-29 06:24:01
问题 I have a simple POJO that I annotated with REST annotations as follows: @GET @Path("/domains/{domainid}") @Override public Domain getDomain(@PathParam("domainid") UUID domainID) throws Exception { logger.info("Retrieving domain "+ domainID); Domain d = null; try { d = MyClient.getDomains().get(domainID.toString()); logger.debug("Returning "+d.getName()); } catch (Exception e) { logger.error("Could not retrieve domain", e); } return d; } Note that the log statement including d.getName() can

What is the proper replacement of the Resteasy 3.X PreProcessInterceptor?

非 Y 不嫁゛ 提交于 2019-12-29 04:29:05
问题 I'm building rest service using an authentication/authorization mechanism as described in this tutorial: http://howtodoinjava.com/2013/06/26/jax-rs-resteasy-basic-authentication-and-authorization-tutorial/ Basically it uses the PreProcessInterceptor interface to scan the target method for annotations (from javax.annotation.security package) which describe the required roles to access that method. As the the authenticator here is an interceptor, it can cancel the target method invocation,