[ https://issues.apache.org/jira/browse/CXF-2335?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12729161#action_12729161 ]
Sergey Beryozkin commented on CXF-2335: --------------------------------------- Thanks for posting the actual test details. JAX-RS spec does not actually provide for the contexts injection into subresource instances. Consider this example : (1) public class GroupsResource { @Path("group") public GroupResource group() { return new GroupResource(); } } and (2) public class GroupsResource { private GroupResource group = new GroupResource(); @Path("group") public GroupResource group() { return group; } } injecting in this last example (2) would not be thread safe. Would you agree ? I reckon it is easy enough for the GroupsResource class to manage the injection into individual subresource GroupResource instances which is what the spec recommends. One would just need to add a setUriInfo with no annotations on GroupResource and in (1) do GroupResource gr = new GroupResource() gr.setUriInfo(uriInfo) in (2) you can add a setter as I suggested in the previous email and also inject the provided value into the shared GroupResource at the moment the method is called. I can only see one possible option in resolving this JIRA : if a user configures jaxrs:server to allow for the subresource injection then the runtime will inject into subresources using a field injection if needed but the runtime but it will really work reliably for dynamically created subresource instances, otherwise, as in (2), it will be thread-unsafe > @Context does not work for JAX-RS member fields > ----------------------------------------------- > > Key: CXF-2335 > URL: https://issues.apache.org/jira/browse/CXF-2335 > Project: CXF > Issue Type: Bug > Components: REST > Affects Versions: 2.2.2 > Reporter: Hendy Irawan > > This works in Jersey, but not in CXF: > class ........ { > @Context > private UriInfo context; > } > The alternative, works on both CXF and Jersey: > class ...... { > @GET > public void something(@Context UriInfo context) { > ... > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.