jax-rs

Injecting EJB within JAX-RS resource on JBoss7

天涯浪子 提交于 2020-01-02 07:46:06
问题 I'm wondering why ejb injection into JAX-RS resource (RestEasy on JBoss7) is not working. EJBs are not part of war but its own EJB jar but I supposed this should not be the problem. I'm forced to do the ctx.lookups "workaround", which are not pretty. Am I missing something or it is really not supported to inject EJB like that? Example below does not work with JBoss, but works with Glassfish (sadly I gotta run my application on JBoss) Path("x") @RequestScoped public class UserResource {

How to implement jaxrs Application without web.xml [duplicate]

此生再无相见时 提交于 2020-01-02 06:18:29
问题 This question already has answers here : How to set up JAX-RS Application using annotations only (no web.xml)? (6 answers) Closed 6 years ago . I am trying to deploy a really simple jaxrs application with without a web.xml config and cannot get it working. My URL I'd expect to access is serverandport/{appname}/rest/welcomes/hello and I think I must be missing something dead obvious. Application @ApplicationPath("/rest") public class EngineApp extends Application { @Override public Set<Class<?

Unable to inject @ApplicationScoped bean in JAX-RS service

空扰寡人 提交于 2020-01-02 04:10:30
问题 I've created JAX-RS service in which I want to inject an application scoped bean. The problem is that the bean is not injected. How is this caused and how can I solve it? JAX-RS service: @Path("room") public class RoomService { @Inject GameController gc; public RoomService() {} @Path("create") @GET @Produces("application/json") public String create() { Room r = new Room(); gc.addRoom(r); // gc is null return r.toJson(); } } Application scoped bean import java.util.ArrayList; import javax

Authorization with RolesAllowedDynamicFeature and Jersey

冷暖自知 提交于 2020-01-02 02:38:10
问题 I'm trying to authenticate users with a JAX-RS filter what seems to work so far. This is the filter where I'm setting a new SecurityContext: @Provider public class AuthenticationFilter implements ContainerRequestFilter { @Override public void filter(final ContainerRequestContext requestContext) throws IOException { requestContext.setSecurityContext(new SecurityContext() { @Override public Principal getUserPrincipal() { return new Principal() { @Override public String getName() { return "Joe";

Jersey/JAX-RS : Return Content-Length in response header instead of chunked transfer encoding

淺唱寂寞╮ 提交于 2020-01-02 01:45:27
问题 I'm using Jersey to create RESTful API resources, and ResponseBuilder to generate the response. Example code for the RESTful resource: public class infoResource{ @GET @Path("service/{id}") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getCompany(@PathParam("id")String id) { //company is just a POJO. Company company = getCompany(id); return Response.status(200).entity(company).build(); } } In the response, it's returning chunked transfer encoding in the

Jersey: JSON and StringMessageProvider clash, application/json methods generate invalid JSON

为君一笑 提交于 2020-01-01 19:33:42
问题 I have a jax-rs web services on jetty+jersey and tried different JSON message providers (e.g. Jackson and Gson). With all of them POJO <-> JSON works just fine but methods like this: @GET @Path("test") @Produces(MediaType.APPLICATION_JSON) public String test() { return "This string should be \"quoted\" by message writer"; } produce string This string should be "quoted" by message writer which is of course not a valid JSON and causes browser's ajax calls to fail. I expect it to be "This string

How to deal with input parameter in CXF request handler in general?

不羁的心 提交于 2020-01-01 12:09:34
问题 I have been doing some work with apache CXF(version 2.2.2) JAX-RS. I am trying to introduce data validation layer in CXF request handler before business method be invoked. Fortunately :), I am encountering an issue on input parameter handling in request handler(DataValidationHandler). I can read the JSON Object manually by following code lines in request handler. But it's duplicated with JSONProvider registered in CXF framework. Because JSON object input stream only can be read once,

How do I set Content-Length when returning large objects in Jersey JAX-RS server

喜欢而已 提交于 2020-01-01 12:04:19
问题 I sometimes want to return a large (several MB) binary object as a response from a JAX-RS resource method. I know the size of the object, and I want the Content-Length header to be set on the response, and I don't want chunked transfer encoding to be used. In Jersey 1.x, I solved this with a custom MessageBodyWriter: public class Blob { public InputStream stream; public long length; } @Provider public class BlobWriter extends MessageBodyWriter<Blob> { public boolean isWriteable(Class<?> type,

Suggestions for OAuth2 libraries for integration with Jersey? [closed]

懵懂的女人 提交于 2020-01-01 09:39:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I am working on making Jersey web services available using OAuth2 to other clients and am having a tough time finding libraries that tie in nicely with Jersey. So far I have looked at the following libraries. http://static.springsource.org/spring-security/oauth/support.html We got the demo working, but do not want

Suggestions for OAuth2 libraries for integration with Jersey? [closed]

倾然丶 夕夏残阳落幕 提交于 2020-01-01 09:39:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I am working on making Jersey web services available using OAuth2 to other clients and am having a tough time finding libraries that tie in nicely with Jersey. So far I have looked at the following libraries. http://static.springsource.org/spring-security/oauth/support.html We got the demo working, but do not want