Re: [Resteasy-users] Issue with injected ServletContext in Resteasy/SpringMVC setup

2013-02-06 Thread Bill Burke
log a jira please

On 2/6/2013 12:31 PM, Stephen Gargan wrote:
> 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 condesed down my config into a simple maven based example to
> illustrate. Hopefully someone can point me in a direction that will help
> out here. I'm hoping there is some mechanism to configure resteasy via
> spring that will allow access to the ServletConfig. Any pointers will be
> very greatfully accepted. I'll happily provide any extra info that might
> be required to help troubleshoot.
>
> Thanks kindly,
>
> Regards
>
> Steve.
>
> p.s. apologies for the duplicated mails.
>
>
> --
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb
>
>
>
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] Issue with injected ServletContext in Resteasy/SpringMVC setup

2013-02-06 Thread Stephen Gargan
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 condesed down my config into a simple maven based example to
illustrate. Hopefully someone can point me in a direction that will help
out here. I'm hoping there is some mechanism to configure resteasy via
spring that will allow access to the ServletConfig. Any pointers will be
very greatfully accepted. I'll happily provide any extra info that might be
required to help troubleshoot.

Thanks kindly,

Regards

Steve.

p.s. apologies for the duplicated mails.


resteasy-inject.jar
Description: application/java-archive
--
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] Fwd: Issue with injected ServletContext in Resteasy/SpringMVC setup

2013-02-06 Thread Stephen Gargan
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 condesed down my config into a simple maven based example to
illustrate. Hopefully someone can point me in a direction that will help
out here. I'm hoping there is some mechanism to configure resteasy via
spring that will allow access to the ServletConfig. Any pointers will be
very greatfully accepted. I'll happily provide any extra info that might be
required to help troubleshoot.

Thanks kindly,

Regards

Steve.


resteasy-inject.jar
Description: application/java-archive
--
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users