Two Laptop Bag*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes JAX-RS cannot inject @Resource WebServiceContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "JAX-RS cannot inject @Resource WebServiceContext" Watch "JAX-RS cannot inject @Resource WebServiceContext" New topic
Author

JAX-RS cannot inject @Resource WebServiceContext

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 721
I have a servlet-based JAX-RS example:


When the client connect to this get method using user name as john, the output on the server is:
INFO: GET students/{studentId} [studentId=13005529]
INFO: User principal name injected from @Context security context :john
INFO: Web service context is null.

Obviously, @Context can inject the security context which contains john as the user principal.
But, I think @Resource WebServiceContext only works for JAX-WS service , not JAX-RS service. The WebServiceContext injected is null.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

Himai Minh wrote:But, I think @Resource WebServiceContext only works for JAX-WS service , not JAX-RS service. The WebServiceContext injected is null.

Correct: the WebServiceContext is only for JAX-WS.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAX-RS cannot inject @Resource WebServiceContext
 
Similar Threads
Why @LocalBean is needed to deploy a EJB ?
WebServiceContext or handle to session in CXF JAX-RS implementation
NullPointerException Trying to Get RemoteIP (why?)
How to get Session context in RESTFul services
isUserInRole problem in glassfish (Solved)