jax-rs

simple example using resteasy-jaxrs not working

一曲冷凌霜 提交于 2021-02-19 06:13:29
问题 I can't get the message "hello" when I visit the page. package jaxrs.ressources; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("greeting") public class HelloRessource { @GET @Path("hello") @Produces(MediaType.TEXT_PLAIN) public String sayhello() { return "Hello from JAX-RS"; }} and this class package jaxrs.utilities; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application;

JAX-RS (Jersey 2 implementation) content negotiation with URL extension .xml or .json

妖精的绣舞 提交于 2021-02-19 03:47:07
问题 I've seen a Java RESTFUL webservice, that allowed the content-type to be requested in the URL with an extension at the end, such as .xml .json This is the style of content negotiation I am striving to achieve in my own Web Service. I am aware of the @Produces annotation, and the fact a method can resolve multiple types with the (value = {}) syntax, by adding an Accept header, say with Postman, the Chrome extension. But I'm not sure how to effectively extract out the information in one method,

Resteasy 3 @Context HttpServletRequest always null

六月ゝ 毕业季﹏ 提交于 2021-02-18 19:48:20
问题 We were using Resteasy 2 but we are upgrading to Resteasy 3 and the HttpServletRequest injection is always null . Our modified security interceptor/filter that looks like: @Provider @ServerInterceptor @Precedence("SECURITY") public class SecurityInterceptor implements ContainerRequestFilter, ContainerResponseFilter { @Context private HttpServletRequest servletRequest; @Override public void filter(ContainerRequestContext requestContext) throws IOException { // Need access to "servletRequest"

Resteasy 3 @Context HttpServletRequest always null

佐手、 提交于 2021-02-18 19:45:33
问题 We were using Resteasy 2 but we are upgrading to Resteasy 3 and the HttpServletRequest injection is always null . Our modified security interceptor/filter that looks like: @Provider @ServerInterceptor @Precedence("SECURITY") public class SecurityInterceptor implements ContainerRequestFilter, ContainerResponseFilter { @Context private HttpServletRequest servletRequest; @Override public void filter(ContainerRequestContext requestContext) throws IOException { // Need access to "servletRequest"

Resteasy 3 @Context HttpServletRequest always null

心已入冬 提交于 2021-02-18 19:45:22
问题 We were using Resteasy 2 but we are upgrading to Resteasy 3 and the HttpServletRequest injection is always null . Our modified security interceptor/filter that looks like: @Provider @ServerInterceptor @Precedence("SECURITY") public class SecurityInterceptor implements ContainerRequestFilter, ContainerResponseFilter { @Context private HttpServletRequest servletRequest; @Override public void filter(ContainerRequestContext requestContext) throws IOException { // Need access to "servletRequest"

File upload endpoint need to close InputStream?

喜夏-厌秋 提交于 2021-02-18 18:20:25
问题 @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/upload") public String upload(@FormDataParam("file") InputStream inputStream) { ... inputStream.close(); // necessary? } For an API endpoint that accepts a file input, do we need to manually close the InputStream or does the framework do it for us? I have checked the Jersey docs but could not find any information about it. Looking for credible source or some way to validate it. 回答1: It is your responsibility to close InputStream. Jersey

File upload endpoint need to close InputStream?

懵懂的女人 提交于 2021-02-18 18:20:07
问题 @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/upload") public String upload(@FormDataParam("file") InputStream inputStream) { ... inputStream.close(); // necessary? } For an API endpoint that accepts a file input, do we need to manually close the InputStream or does the framework do it for us? I have checked the Jersey docs but could not find any information about it. Looking for credible source or some way to validate it. 回答1: It is your responsibility to close InputStream. Jersey

What is the equivalent of @Context UriInfo in Spring Rest

五迷三道 提交于 2021-02-18 10:40:07
问题 I have worked in Jersey and RESTEasy framework earlier and now we will be using Spring Rest for a new project , I don't want to pass all the query params and matrix params as parameters in the method , and usually I would annotate the method with @Context UriInfo and would get all the parameters inside my method in Jersey or RESTEasy Framework for complex parameters. I would like to know if there is any @Context UriInfo in Spring REST, which is similar to RESTEasy or Jersey Framework. I would

Does Tomcat support JAX-RS out of the box (is it JAX-RS aware)?

折月煮酒 提交于 2021-02-17 14:56:12
问题 From the textbook "RESTful Java with JAX-RS" we can read: If our application server is JAX-RS-aware or, in other words, is tightly integrated with JAX-RS declare our ShoppingApplication class as a servlet: <?xml version="1.0"?> <web-app> <servlet> <servlet-name>Rest</servlet-name> <servlet-class> com.restfully.shop.services.ShoppingApplication </servlet-class> </servlet> <servlet-mapping> <servlet-name>Rest</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app> If our

How to set the Host header in JAX-RS / Apache CXF

自古美人都是妖i 提交于 2021-02-11 14:46:25
问题 I am trying to access a service over HTTPS but due to restrictive network settings I am trying to make the request through an ssh tunnel. I create the tunnel with a command like: ssh -L 9443:my-service.com:443 sdt-jump-server The service is only available via HTTPS, its hosted with a self-signed certificate, and it is behind a load-balancer that uses either the hostname or an explicit Host header to route incoming requests to the appropriate backend service. I am able to invoke the endpoint