Hi,
I'm currently looking at migrating a Jersey 1 application to Jersey 2.
One of the features we utilise is the ability in Jersey 1 to update the 
ResourceConfig singletons collection at runtime. This gives us the ability 
to add/remove Resource endpoints at runtime in a dynamic manner.
Basically, we instantiate Resources using OSGi then dynamically add or 
remove the instance using config.getSingletons().remove(resource) and 
config.getSingletons().add(resource); and then calling container.reload();
Jersey 2 has made this Collection un-modifiable now, and also the 
ResourceConfig getSingletons() is now final so can't be overridden 
(without violating the intent of the developer).
I'm try to use the HK Binder module to bind the instance (using 
bind(object).to(blah.class) and passing the instance of the AbstractBinder 
to config.registerInstances(), but I'm getting the following stacktrace 
when I try to call the endpoint:
javax.servlet.ServletException: java.lang.IllegalStateException: Request 
scope has been already shut down.
        at 
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489)
        at 
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
        at 
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
        at 
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
        at 
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
        at 
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1290)
        at 
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:778)
        at 
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:475)
        at 
com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:152)
        at 
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:94)
        at 
com.ibm.ws.app.manager.wab.internal.OsgiDirectoryProtectionFilter.doFilter(OsgiDirectoryProtectionFilter.java:101)
        at 
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:207)
        at 
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) 
Thanks in advance,
Kevin Kilroy
Software Engineering | Bankwest Enterprise Services
Level 3D Bankwest Place 300 Murray Street Perth WA 6000
p | (08) 9369 7385  e | kevin.kilroy_at_bankwest.com.au 
› www.bankwest.com.au › find us on   
_______________________________________________________________________________
Unencrypted electronic mail is not secure and may not be authentic.
If you have any doubts as to the contents please telephone to confirm.
This electronic transmission including any attachments is intended only
for those to whom it is addressed. It may contain copyright material or
information that is confidential, privileged or exempt from disclosure by law.
Any claim to privilege is not waived or lost by reason of mistaken transmission
of this information. If you are not the intended recipient you must not
distribute or copy this transmission and should please notify the sender.
Your costs for doing this will be reimbursed by the sender.
We do not accept liability in connection with computer virus, data corruption,
delay, interruption, unauthorised access or unauthorised amendment.
_______________________________________________________________________________
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit 
http://www.symanteccloud.com
______________________________________________________________________