Skip to content

resolve null @Context in Spring-proxied Jersey resources#6080

Open
wokis wants to merge 2 commits intoeclipse-ee4j:4.xfrom
wokis:spring-aop-inject-fix
Open

resolve null @Context in Spring-proxied Jersey resources#6080
wokis wants to merge 2 commits intoeclipse-ee4j:4.xfrom
wokis:spring-aop-inject-fix

Conversation

@wokis
Copy link

@wokis wokis commented Mar 17, 2026

When using @RolesAllowed or other Spring AOP features, Spring wraps resources in CGLIB proxies. Jersey's InjectionManager was previously injecting into the outermost proxy, but CGLIB does not delegate field access to the target instance.

This change recursively unwraps the Spring proxy chain to find the ultimate target POJO and performs HK2 injection directly on that instance, ensuring @Context fields (like HttpServletRequest) are available during method execution.

This should fix issues from #3398 and #3465.

wokis added 2 commits March 17, 2026 17:09
When using @RolesAllowed or other Spring AOP features, Spring wraps resources in CGLIB proxies. Jersey's InjectionManager was previously injecting into the outermost proxy, but CGLIB does not delegate field access to the target instance.

This change recursively unwraps the Spring proxy chain to find the ultimate target POJO and performs HK2 injection directly on that instance, ensuring @context fields (like HttpServletRequest) are available during method execution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants