This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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: 1032
    
    4
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
Saloon Keeper

Joined: Apr 07, 2010
Posts: 2007
    
  39

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
 
It's not a secret anymore!