aspose 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 Spring in Action this week in the Spring 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: 775
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: 1696
    
  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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAX-RS cannot inject @Resource WebServiceContext