You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Moritz Gmelin <mo...@gmx.de> on 2010/10/26 09:58:46 UTC

Re: tapestry-resteasy NPE when trying to access session [solved]

Yes,

I moved down the RestEasyRequest handler into the RequestFilter chain and now I can even inject my SessionStateObjects. Great. 
I want to use those SessionStateObjects to forward authentication information for the REST services. Within the single request. To be able to authenticate either with the browser session or via OAuth2. It is not meant to keep a session in place for the REST service itself.

No do you see a chance to add the java classes under my .rest. package in the LiveClassReloading system? Is there some configuration where I can add package names that should be monitored?

Thanks

Moritz

Am 26.10.2010 um 09:25 schrieb Alejandro Scandroli:

> You are right, the Request is not yet available. The RESTEasy filter
> is a HttpServletRequestFilter not a RequestFilter, so you need to
> inject the HttpServletRequest to make it work.
> Try this:
> 
> 	@Inject
> 	private HttpServletRequest request;
> 
> BTW, remember that sessions should be irrelevant in a REST environment.
> 
> Saludos.
> Alejandro.
> 
> 
> On Mon, Oct 25, 2010 at 9:36 PM, Josh Canfield <jo...@gmail.com> wrote:
>>> ?? I don't understand your question. I beleive that tapestry-resteasy does this for me.
>> Hm. RESTEasy is a jboss project, I assumed you were rolling your own
>> tapestry integration since you didn't mention anything about using a
>> third party library for doing that integration.
>> 
>>> Could it be that since the tapestry-resteasy HttpServletRequestHandler is placed before:GZIP, tapestry has not yet initialized its RequestGlobals and thus the session information is not yet available where reasteasy handles its service methods?
>> 
>> I don't use tynamo so I don't know what they are doing, but I'd guess
>> that something like you've suggested is the culprit.
>> 
>> Josh
>> 
>> 
>> On Mon, Oct 25, 2010 at 12:15 PM, Moritz Gmelin <mo...@gmx.de> wrote:
>>> ?? I don't understand your question. I beleive that tapestry-resteasy does this for me.
>>> 
>>> Could it be that since the tapestry-resteasy HttpServletRequestHandler is placed before:GZIP, tapestry has not yet initialized its RequestGlobals and thus the session information is not yet available where reasteasy handles its service methods?
>>> 
>>> M.
>>> 
>>> 
>>> Am 25.10.2010 um 18:30 schrieb Josh Canfield:
>>> 
>>>>> I'd like to get access to the current session from inside my resteasy handler methods.
>>>> How are you creating your resteasy handler?
>>>> 
>>>> On Mon, Oct 25, 2010 at 3:06 AM, Moritz Gmelin <mo...@gmx.de> wrote:
>>>>> Hi,
>>>>> 
>>>>> I'd like to get access to the current session from inside my resteasy handler methods. But when I inject the request and call getSession() on it, I get a NullPointerException.
>>>>> My original goal was to get access to SessionState objects from tapestry by calling the ApplicationStateManager.get() method with our SessionState object. But this fails for the same reason.
>>>>> Why is the session object not accessible from the injected Request object in a ResteasyHandler?
>>>>> 
>>>>> The code below will throw an exception on the line request.getSession(false).
>>>>> 
>>>>> @Path("/resttest")
>>>>> public class TestResource
>>>>> {
>>>>> 
>>>>>        @Inject
>>>>>        private Request request;
>>>>> 
>>>>>        @Inject
>>>>>        private ApplicationStateManager asm;
>>>>> 
>>>>>        @InjectResource
>>>>>        private Logger log;
>>>>> 
>>>>> 
>>>>>        @GET
>>>>>        @Produces("text/xml")
>>>>>        public List<TestEntity> getEntityList()
>>>>>        {
>>>>> 
>>>>>                log.warn("REST Request in request " + request);
>>>>>                log.warn("REST Request in session2 " + request.getSession(false));
>>>>> 
>>>>> 
>>>>> M.
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> 
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org