-
Bug
-
Resolution: Done
-
Minor
-
2.3.5.Final, 3.0.4.Final, 3.6.2.Final
I'm having an issue retrieving servlet parameters with a springmvc resteasy setup using 2.3.5.Final. A class that I have no control over uses the @Context to inject the ServletConfig so that it can look up an init-param. When this class asks the injected context for the param an exception is thrown saying
org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.servlet.ServletContext
Digging in a little further showed that its a proxy for the ServletContext gets injected into the class; a ContextParameterInjector$GenericDelegatingProxy specifically. When the 'getInitParameter' method is called on the proxy, it calls to the to the ResteasyProviderFactory to retrieve the ServletContext. This context is missing and so the above exception gets thrown.
From what I can tell, it seems that the deploment gets configured differently using springmvc-resteasy.xml than it otherwise might with the plain ResteasyBootstrap. I'm thinking it boils down the the init method in the ServletContainerDispatcher, if the app is bootstrapped outside of spring it causes the following code to be run
lines 86...89
dispatcher.getDefaultContextObjects().put(Application.class, app);
// push context data so we can inject it
Map contextDataMap = ResteasyProviderFactory.getContextDataMap();
contextDataMap.putAll(dispatcher.getDefaultContextObjects());
And this makes the ServletContext available via the provider factory and subsequently for injection. When spring initializes the deployment the other path is taken and this is not called.
I've condensed down my config into a simple maven based example to illustrate. I'll happily provide any extra info that might be required to help troubleshoot.
Thanks kindly,
Regards
Steve.
- is related to
-
RESTEASY-2168 /actuator does not work when using @ApplicationPath("/")
- Resolved
- relates to
-
RESTEASY-2392 Complete Spring integration documentation
- Resolved