Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAX-RS cannot inject @Resource WebServiceContext

 
Himai Minh
Ranch Hand
Posts: 1229
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 2275
81
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic