File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 739
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: 1662
    
  25

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.
 
 
subject: JAX-RS cannot inject @Resource WebServiceContext