You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Inge Solvoll <in...@gmail.com> on 2009/12/07 11:31:44 UTC

Exception accessing T5 Registry from other servlet

Hi!

I'm trying to integrate my T5 IOC Registry with the non-T5 part of our
application. But when I try to actually use services that are perthread and
depend on session data, I get the error listed below. It seems that the
request or the session hasn't been initialized properly for the request.
This is a request for a page that is in my "ignoredPaths" list, so it is
ignored by tapestry. Is that the reason why I get this error? Or is it
perhaps affected by the order of my servlet filters?


Caused by: java.lang.NullPointerException
	at $Request_12568a717d3.getSession($Request_12568a717d3.java)
	at $Request_12568a717a6.getSession($Request_12568a717a6.java)
	at org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)
	at org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.get(SessionApplicationStatePersistenceStrategy.java:44)
	at $ApplicationStatePersistenceStrategy_12568a717d2.get($ApplicationStatePersistenceStrategy_12568a717d2.java)
	at org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.getOrCreate(ApplicationStateManagerImpl.java:45)
	at org.apache.tapestry5.internal.services.ApplicationStateManagerImpl.get(ApplicationStateManagerImpl.java:126)
	at $ApplicationStateManager_12568a717ce.get($ApplicationStateManager_12568a717ce.java)
	at our.application.tapestry5.services.UserWrapperImpl.getUser(UserWrapperImpl.java:16)
	at $UserWrapper_12568a71857.getUser($UserWrapper_12568a71857.java)
	at our.application.tapestry5.services.MyServiceImpl.isEnabled(MyServiceImpl.java:41)



Here's the service implementation with the error:

public class UserWrapperImpl implements UserWrapper {

private final ApplicationStateManager asm;

  public UserWrapperImpl(ApplicationStateManager asm) {
    this.asm = asm;
  }

  public User getUser() {
    return asm.get(User.class);
  }

}

Re: Exception accessing T5 Registry from other servlet

Posted by Igor Drobiazko <ig...@gmail.com>.
On Mon, Dec 7, 2009 at 5:58 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

>
> I've been planning to add a simpler alternative to
> SessionStateObjects, an annotation that simply says "store this value
> in the session with this explicit key", to make coordinating a T5 app
> with a legacy app simpler.
>

It's already there ;)
http://tapestry.formos.com/nightly/tapestry5/apidocs/org/apache/tapestry5/annotations/SessionAttribute.html

-- 
Best regards,

Igor Drobiazko
http://tapestry5.de/blog

Re: Exception accessing T5 Registry from other servlet

Posted by Inge Solvoll <in...@gmail.com>.
I succeeded on this in Struts now, it works nicely and I'm cleaning up the
registry by subclassing the struts action servlet and doing try-finally.

One problem left:

I'm using Sitemesh with T4. In my sitemesh decorator jsp, I'm referencing a
custom tag that references a T5 service that references
request.getSession(). Are you following me? :)

I'm getting the same error listed in this thread, request.getSession() gives
a nullpointer. When I remove the sitemesh filter, my T4 page renders as
expected. I've tried moving the sitemesh filter before and after the T5
filter, no change.



On Mon, Dec 7, 2009 at 7:42 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> I would put the cleanup in a try { } finally { } inside your servlet's
> doGet().
>
> On Mon, Dec 7, 2009 at 10:29 AM, Inge Solvoll <in...@gmail.com>
> wrote:
> > Ok, let's see if I've understood this correctly:
> >
> > Tapestry has already invoked Registry.cleanupThread() for the current
> > (ignored) request before passing it on to some other servlet/resource.
> This
> > cleanup removed my Request/Response objects. Now when I put new
> > Request/Response instances back in the game with my mod, I need to
> perform
> > cleanup once more because Tapestry already did and gave away control. It
> no
> > longer knows when to clean up.
> >
> > Right?
> >
> > So now the only thing left to do is to find out where to put my cleanup
> > invocation. Hints anyone? I know I should be able to figure it out
> myself,
> > and I will try, but no harm done if anyone beats me to it :)
> >
> > Thanks for great help so far!
> > Inge
> >
> > On Mon, Dec 7, 2009 at 5:58 PM, Howard Lewis Ship <hl...@gmail.com>
> wrote:
> >
> >> On Mon, Dec 7, 2009 at 7:11 AM, Inge Solvoll <in...@gmail.com>
> >> wrote:
> >> > Found something that seems to work by reading carefully through
> >> > TapestryModule.java, see code below. To me, it seems strange that I
> have
> >> to
> >> > do this. Do any of you guys see anything wrong with this?
> >> >
> >>
> >> Since it's not a Tapestry-related request, control has passed out of
> >> the TapestryFilter and on to other servlets within the web
> >> application. Tapestry has already cleaned up the RequestGlobals
> >> object, a per-thread service that stores the HttpServletRequest and
> >> (Tapestry) Request objects.
> >>
> >> You want to make sure to invoke the Registry.cleanupThread() method at
> >> the end of your request.
> >>
> >> I've been planning to add a simpler alternative to
> >> SessionStateObjects, an annotation that simply says "store this value
> >> in the session with this explicit key", to make coordinating a T5 app
> >> with a legacy app simpler.
> >>
> >>
> >> >  public void
> >> >
> >>
> contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter>
> >> > configuration, @Inject @Symbol(SymbolConstants.CHARSET) final String
> >> > applicationCharset, @Primary final SessionPersistedObjectAnalyzer
> >> analyzer,
> >> > final RequestGlobals requestGlobals) {
> >> >
> >> >    HttpServletRequestFilter storeRequestResponse = new
> >> > HttpServletRequestFilter() {
> >> >
> >> >      public boolean service(HttpServletRequest servletRequest,
> >> > HttpServletResponse servletResponse, HttpServletRequestHandler
> handler)
> >> > throws IOException {
> >> >        Request request = new RequestImpl(servletRequest,
> >> > applicationCharset, analyzer);
> >> >        Response response = new ResponseImpl(servletResponse);
> >> >        requestGlobals.storeRequestResponse(request, response);
> >> >        return handler.service(servletRequest, servletResponse);
> >> >      }
> >> >    };
> >> >
> >> >    configuration.add("StoreRequestResponse", storeRequestResponse,
> >> > "before:*");
> >> >  }
> >> >
> >> >
> >> > On Mon, Dec 7, 2009 at 2:35 PM, Inge Solvoll <inge.tapestry@gmail.com
> >> >wrote:
> >> >
> >> >> Thanks!
> >> >>
> >> >> Didn't work though. Tried running
> >> >> requestGlobals.storeServletRequestResponse before asm.get(...), still
> >> same
> >> >> error because requestGlobals.getRequest() is still null after storing
> >> >> httprequest.
> >> >>
> >> >> I discovered that requestGlobals.getHTTPServletRequest() returns a
> live
> >> and
> >> >> working request, while requestGlobals.getRequest() returns null. I
> also
> >> put
> >> >> a breakpoint in TapestryModule "StoreIntoGlobals", and it is run
> before
> >> my
> >> >> code.
> >> >>
> >> >> So, the Request and Response properties of requestGlobals aren't
> >> populated
> >> >> when using the Registry from another servlet i think. Am I right? Is
> >> there
> >> >> any way to make this work?
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> On Mon, Dec 7, 2009 at 1:16 PM, Thiago H. de Paula Figueiredo <
> >> >> thiagohp@gmail.com> wrote:
> >> >>
> >> >>> Em Mon, 07 Dec 2009 08:31:44 -0200, Inge Solvoll <
> >> inge.tapestry@gmail.com>
> >> >>> escreveu:
> >> >>>
> >> >>>  Hi!
> >> >>>>
> >> >>>
> >> >>> Hi!
> >> >>>
> >> >>>
> >> >>>
> >> >>>> Caused by: java.lang.NullPointerException
> >> >>>>        at
> $Request_12568a717d3.getSession($Request_12568a717d3.java)
> >> >>>>        at
> $Request_12568a717a6.getSession($Request_12568a717a6.java)
> >> >>>>        at
> >> >>>>
> >>
> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)
> >> >>>>
> >> >>>
> >> >>> It looks like the Request wasnt. Try getting the RequestGlobals
> service
> >> >>> and invoking the storeServletRequestResponse() method before you use
> >> the
> >> >>> ApplicationStateManager.
> >> >>>
> >> >>> --
> >> >>> Thiago H. de Paula Figueiredo
> >> >>> Independent Java, Apache Tapestry 5 and Hibernate consultant,
> >> developer,
> >> >>> and instructor
> >> >>> Owner, software architect and developer, Ars Machina Tecnologia da
> >> >>> Informação Ltda.
> >> >>> http://www.arsmachina.com.br
> >> >>>
> >> >>>
> ---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >> >>>
> >> >>>
> >> >>
> >> >
> >>
> >>
> >>
> >> --
> >> Howard M. Lewis Ship
> >>
> >> Creator of Apache Tapestry
> >>
> >> The source for Tapestry training, mentoring and support. Contact me to
> >> learn how I can get you up and productive in Tapestry fast!
> >>
> >> (971) 678-5210
> >> http://howardlewisship.com
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Exception accessing T5 Registry from other servlet

Posted by Howard Lewis Ship <hl...@gmail.com>.
I would put the cleanup in a try { } finally { } inside your servlet's doGet().

On Mon, Dec 7, 2009 at 10:29 AM, Inge Solvoll <in...@gmail.com> wrote:
> Ok, let's see if I've understood this correctly:
>
> Tapestry has already invoked Registry.cleanupThread() for the current
> (ignored) request before passing it on to some other servlet/resource. This
> cleanup removed my Request/Response objects. Now when I put new
> Request/Response instances back in the game with my mod, I need to perform
> cleanup once more because Tapestry already did and gave away control. It no
> longer knows when to clean up.
>
> Right?
>
> So now the only thing left to do is to find out where to put my cleanup
> invocation. Hints anyone? I know I should be able to figure it out myself,
> and I will try, but no harm done if anyone beats me to it :)
>
> Thanks for great help so far!
> Inge
>
> On Mon, Dec 7, 2009 at 5:58 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
>
>> On Mon, Dec 7, 2009 at 7:11 AM, Inge Solvoll <in...@gmail.com>
>> wrote:
>> > Found something that seems to work by reading carefully through
>> > TapestryModule.java, see code below. To me, it seems strange that I have
>> to
>> > do this. Do any of you guys see anything wrong with this?
>> >
>>
>> Since it's not a Tapestry-related request, control has passed out of
>> the TapestryFilter and on to other servlets within the web
>> application. Tapestry has already cleaned up the RequestGlobals
>> object, a per-thread service that stores the HttpServletRequest and
>> (Tapestry) Request objects.
>>
>> You want to make sure to invoke the Registry.cleanupThread() method at
>> the end of your request.
>>
>> I've been planning to add a simpler alternative to
>> SessionStateObjects, an annotation that simply says "store this value
>> in the session with this explicit key", to make coordinating a T5 app
>> with a legacy app simpler.
>>
>>
>> >  public void
>> >
>> contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter>
>> > configuration, @Inject @Symbol(SymbolConstants.CHARSET) final String
>> > applicationCharset, @Primary final SessionPersistedObjectAnalyzer
>> analyzer,
>> > final RequestGlobals requestGlobals) {
>> >
>> >    HttpServletRequestFilter storeRequestResponse = new
>> > HttpServletRequestFilter() {
>> >
>> >      public boolean service(HttpServletRequest servletRequest,
>> > HttpServletResponse servletResponse, HttpServletRequestHandler handler)
>> > throws IOException {
>> >        Request request = new RequestImpl(servletRequest,
>> > applicationCharset, analyzer);
>> >        Response response = new ResponseImpl(servletResponse);
>> >        requestGlobals.storeRequestResponse(request, response);
>> >        return handler.service(servletRequest, servletResponse);
>> >      }
>> >    };
>> >
>> >    configuration.add("StoreRequestResponse", storeRequestResponse,
>> > "before:*");
>> >  }
>> >
>> >
>> > On Mon, Dec 7, 2009 at 2:35 PM, Inge Solvoll <inge.tapestry@gmail.com
>> >wrote:
>> >
>> >> Thanks!
>> >>
>> >> Didn't work though. Tried running
>> >> requestGlobals.storeServletRequestResponse before asm.get(...), still
>> same
>> >> error because requestGlobals.getRequest() is still null after storing
>> >> httprequest.
>> >>
>> >> I discovered that requestGlobals.getHTTPServletRequest() returns a live
>> and
>> >> working request, while requestGlobals.getRequest() returns null. I also
>> put
>> >> a breakpoint in TapestryModule "StoreIntoGlobals", and it is run before
>> my
>> >> code.
>> >>
>> >> So, the Request and Response properties of requestGlobals aren't
>> populated
>> >> when using the Registry from another servlet i think. Am I right? Is
>> there
>> >> any way to make this work?
>> >>
>> >>
>> >>
>> >>
>> >> On Mon, Dec 7, 2009 at 1:16 PM, Thiago H. de Paula Figueiredo <
>> >> thiagohp@gmail.com> wrote:
>> >>
>> >>> Em Mon, 07 Dec 2009 08:31:44 -0200, Inge Solvoll <
>> inge.tapestry@gmail.com>
>> >>> escreveu:
>> >>>
>> >>>  Hi!
>> >>>>
>> >>>
>> >>> Hi!
>> >>>
>> >>>
>> >>>
>> >>>> Caused by: java.lang.NullPointerException
>> >>>>        at $Request_12568a717d3.getSession($Request_12568a717d3.java)
>> >>>>        at $Request_12568a717a6.getSession($Request_12568a717a6.java)
>> >>>>        at
>> >>>>
>> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)
>> >>>>
>> >>>
>> >>> It looks like the Request wasnt. Try getting the RequestGlobals service
>> >>> and invoking the storeServletRequestResponse() method before you use
>> the
>> >>> ApplicationStateManager.
>> >>>
>> >>> --
>> >>> Thiago H. de Paula Figueiredo
>> >>> Independent Java, Apache Tapestry 5 and Hibernate consultant,
>> developer,
>> >>> and instructor
>> >>> Owner, software architect and developer, Ars Machina Tecnologia da
>> >>> Informação Ltda.
>> >>> http://www.arsmachina.com.br
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >>> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>>
>> >>>
>> >>
>> >
>>
>>
>>
>> --
>> Howard M. Lewis Ship
>>
>> Creator of Apache Tapestry
>>
>> The source for Tapestry training, mentoring and support. Contact me to
>> learn how I can get you up and productive in Tapestry fast!
>>
>> (971) 678-5210
>> http://howardlewisship.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: Exception accessing T5 Registry from other servlet

Posted by Inge Solvoll <in...@gmail.com>.
Ok, let's see if I've understood this correctly:

Tapestry has already invoked Registry.cleanupThread() for the current
(ignored) request before passing it on to some other servlet/resource. This
cleanup removed my Request/Response objects. Now when I put new
Request/Response instances back in the game with my mod, I need to perform
cleanup once more because Tapestry already did and gave away control. It no
longer knows when to clean up.

Right?

So now the only thing left to do is to find out where to put my cleanup
invocation. Hints anyone? I know I should be able to figure it out myself,
and I will try, but no harm done if anyone beats me to it :)

Thanks for great help so far!
Inge

On Mon, Dec 7, 2009 at 5:58 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> On Mon, Dec 7, 2009 at 7:11 AM, Inge Solvoll <in...@gmail.com>
> wrote:
> > Found something that seems to work by reading carefully through
> > TapestryModule.java, see code below. To me, it seems strange that I have
> to
> > do this. Do any of you guys see anything wrong with this?
> >
>
> Since it's not a Tapestry-related request, control has passed out of
> the TapestryFilter and on to other servlets within the web
> application. Tapestry has already cleaned up the RequestGlobals
> object, a per-thread service that stores the HttpServletRequest and
> (Tapestry) Request objects.
>
> You want to make sure to invoke the Registry.cleanupThread() method at
> the end of your request.
>
> I've been planning to add a simpler alternative to
> SessionStateObjects, an annotation that simply says "store this value
> in the session with this explicit key", to make coordinating a T5 app
> with a legacy app simpler.
>
>
> >  public void
> >
> contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter>
> > configuration, @Inject @Symbol(SymbolConstants.CHARSET) final String
> > applicationCharset, @Primary final SessionPersistedObjectAnalyzer
> analyzer,
> > final RequestGlobals requestGlobals) {
> >
> >    HttpServletRequestFilter storeRequestResponse = new
> > HttpServletRequestFilter() {
> >
> >      public boolean service(HttpServletRequest servletRequest,
> > HttpServletResponse servletResponse, HttpServletRequestHandler handler)
> > throws IOException {
> >        Request request = new RequestImpl(servletRequest,
> > applicationCharset, analyzer);
> >        Response response = new ResponseImpl(servletResponse);
> >        requestGlobals.storeRequestResponse(request, response);
> >        return handler.service(servletRequest, servletResponse);
> >      }
> >    };
> >
> >    configuration.add("StoreRequestResponse", storeRequestResponse,
> > "before:*");
> >  }
> >
> >
> > On Mon, Dec 7, 2009 at 2:35 PM, Inge Solvoll <inge.tapestry@gmail.com
> >wrote:
> >
> >> Thanks!
> >>
> >> Didn't work though. Tried running
> >> requestGlobals.storeServletRequestResponse before asm.get(...), still
> same
> >> error because requestGlobals.getRequest() is still null after storing
> >> httprequest.
> >>
> >> I discovered that requestGlobals.getHTTPServletRequest() returns a live
> and
> >> working request, while requestGlobals.getRequest() returns null. I also
> put
> >> a breakpoint in TapestryModule "StoreIntoGlobals", and it is run before
> my
> >> code.
> >>
> >> So, the Request and Response properties of requestGlobals aren't
> populated
> >> when using the Registry from another servlet i think. Am I right? Is
> there
> >> any way to make this work?
> >>
> >>
> >>
> >>
> >> On Mon, Dec 7, 2009 at 1:16 PM, Thiago H. de Paula Figueiredo <
> >> thiagohp@gmail.com> wrote:
> >>
> >>> Em Mon, 07 Dec 2009 08:31:44 -0200, Inge Solvoll <
> inge.tapestry@gmail.com>
> >>> escreveu:
> >>>
> >>>  Hi!
> >>>>
> >>>
> >>> Hi!
> >>>
> >>>
> >>>
> >>>> Caused by: java.lang.NullPointerException
> >>>>        at $Request_12568a717d3.getSession($Request_12568a717d3.java)
> >>>>        at $Request_12568a717a6.getSession($Request_12568a717a6.java)
> >>>>        at
> >>>>
> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)
> >>>>
> >>>
> >>> It looks like the Request wasnt. Try getting the RequestGlobals service
> >>> and invoking the storeServletRequestResponse() method before you use
> the
> >>> ApplicationStateManager.
> >>>
> >>> --
> >>> Thiago H. de Paula Figueiredo
> >>> Independent Java, Apache Tapestry 5 and Hibernate consultant,
> developer,
> >>> and instructor
> >>> Owner, software architect and developer, Ars Machina Tecnologia da
> >>> Informação Ltda.
> >>> http://www.arsmachina.com.br
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Exception accessing T5 Registry from other servlet

Posted by Howard Lewis Ship <hl...@gmail.com>.
On Mon, Dec 7, 2009 at 7:11 AM, Inge Solvoll <in...@gmail.com> wrote:
> Found something that seems to work by reading carefully through
> TapestryModule.java, see code below. To me, it seems strange that I have to
> do this. Do any of you guys see anything wrong with this?
>

Since it's not a Tapestry-related request, control has passed out of
the TapestryFilter and on to other servlets within the web
application. Tapestry has already cleaned up the RequestGlobals
object, a per-thread service that stores the HttpServletRequest and
(Tapestry) Request objects.

You want to make sure to invoke the Registry.cleanupThread() method at
the end of your request.

I've been planning to add a simpler alternative to
SessionStateObjects, an annotation that simply says "store this value
in the session with this explicit key", to make coordinating a T5 app
with a legacy app simpler.


>  public void
> contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter>
> configuration, @Inject @Symbol(SymbolConstants.CHARSET) final String
> applicationCharset, @Primary final SessionPersistedObjectAnalyzer analyzer,
> final RequestGlobals requestGlobals) {
>
>    HttpServletRequestFilter storeRequestResponse = new
> HttpServletRequestFilter() {
>
>      public boolean service(HttpServletRequest servletRequest,
> HttpServletResponse servletResponse, HttpServletRequestHandler handler)
> throws IOException {
>        Request request = new RequestImpl(servletRequest,
> applicationCharset, analyzer);
>        Response response = new ResponseImpl(servletResponse);
>        requestGlobals.storeRequestResponse(request, response);
>        return handler.service(servletRequest, servletResponse);
>      }
>    };
>
>    configuration.add("StoreRequestResponse", storeRequestResponse,
> "before:*");
>  }
>
>
> On Mon, Dec 7, 2009 at 2:35 PM, Inge Solvoll <in...@gmail.com>wrote:
>
>> Thanks!
>>
>> Didn't work though. Tried running
>> requestGlobals.storeServletRequestResponse before asm.get(...), still same
>> error because requestGlobals.getRequest() is still null after storing
>> httprequest.
>>
>> I discovered that requestGlobals.getHTTPServletRequest() returns a live and
>> working request, while requestGlobals.getRequest() returns null. I also put
>> a breakpoint in TapestryModule "StoreIntoGlobals", and it is run before my
>> code.
>>
>> So, the Request and Response properties of requestGlobals aren't populated
>> when using the Registry from another servlet i think. Am I right? Is there
>> any way to make this work?
>>
>>
>>
>>
>> On Mon, Dec 7, 2009 at 1:16 PM, Thiago H. de Paula Figueiredo <
>> thiagohp@gmail.com> wrote:
>>
>>> Em Mon, 07 Dec 2009 08:31:44 -0200, Inge Solvoll <in...@gmail.com>
>>> escreveu:
>>>
>>>  Hi!
>>>>
>>>
>>> Hi!
>>>
>>>
>>>
>>>> Caused by: java.lang.NullPointerException
>>>>        at $Request_12568a717d3.getSession($Request_12568a717d3.java)
>>>>        at $Request_12568a717a6.getSession($Request_12568a717a6.java)
>>>>        at
>>>> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)
>>>>
>>>
>>> It looks like the Request wasnt. Try getting the RequestGlobals service
>>> and invoking the storeServletRequestResponse() method before you use the
>>> ApplicationStateManager.
>>>
>>> --
>>> Thiago H. de Paula Figueiredo
>>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>>> and instructor
>>> Owner, software architect and developer, Ars Machina Tecnologia da
>>> Informação Ltda.
>>> http://www.arsmachina.com.br
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: Exception accessing T5 Registry from other servlet

Posted by Inge Solvoll <in...@gmail.com>.
Found something that seems to work by reading carefully through
TapestryModule.java, see code below. To me, it seems strange that I have to
do this. Do any of you guys see anything wrong with this?

  public void
contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter>
configuration, @Inject @Symbol(SymbolConstants.CHARSET) final String
applicationCharset, @Primary final SessionPersistedObjectAnalyzer analyzer,
final RequestGlobals requestGlobals) {

    HttpServletRequestFilter storeRequestResponse = new
HttpServletRequestFilter() {

      public boolean service(HttpServletRequest servletRequest,
HttpServletResponse servletResponse, HttpServletRequestHandler handler)
throws IOException {
        Request request = new RequestImpl(servletRequest,
applicationCharset, analyzer);
        Response response = new ResponseImpl(servletResponse);
        requestGlobals.storeRequestResponse(request, response);
        return handler.service(servletRequest, servletResponse);
      }
    };

    configuration.add("StoreRequestResponse", storeRequestResponse,
"before:*");
  }


On Mon, Dec 7, 2009 at 2:35 PM, Inge Solvoll <in...@gmail.com>wrote:

> Thanks!
>
> Didn't work though. Tried running
> requestGlobals.storeServletRequestResponse before asm.get(...), still same
> error because requestGlobals.getRequest() is still null after storing
> httprequest.
>
> I discovered that requestGlobals.getHTTPServletRequest() returns a live and
> working request, while requestGlobals.getRequest() returns null. I also put
> a breakpoint in TapestryModule "StoreIntoGlobals", and it is run before my
> code.
>
> So, the Request and Response properties of requestGlobals aren't populated
> when using the Registry from another servlet i think. Am I right? Is there
> any way to make this work?
>
>
>
>
> On Mon, Dec 7, 2009 at 1:16 PM, Thiago H. de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
>> Em Mon, 07 Dec 2009 08:31:44 -0200, Inge Solvoll <in...@gmail.com>
>> escreveu:
>>
>>  Hi!
>>>
>>
>> Hi!
>>
>>
>>
>>> Caused by: java.lang.NullPointerException
>>>        at $Request_12568a717d3.getSession($Request_12568a717d3.java)
>>>        at $Request_12568a717a6.getSession($Request_12568a717a6.java)
>>>        at
>>> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)
>>>
>>
>> It looks like the Request wasnt. Try getting the RequestGlobals service
>> and invoking the storeServletRequestResponse() method before you use the
>> ApplicationStateManager.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and instructor
>> Owner, software architect and developer, Ars Machina Tecnologia da
>> Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: Exception accessing T5 Registry from other servlet

Posted by Inge Solvoll <in...@gmail.com>.
Thanks!

Didn't work though. Tried running requestGlobals.storeServletRequestResponse
before asm.get(...), still same error because requestGlobals.getRequest() is
still null after storing httprequest.

I discovered that requestGlobals.getHTTPServletRequest() returns a live and
working request, while requestGlobals.getRequest() returns null. I also put
a breakpoint in TapestryModule "StoreIntoGlobals", and it is run before my
code.

So, the Request and Response properties of requestGlobals aren't populated
when using the Registry from another servlet i think. Am I right? Is there
any way to make this work?



On Mon, Dec 7, 2009 at 1:16 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> Em Mon, 07 Dec 2009 08:31:44 -0200, Inge Solvoll <in...@gmail.com>
> escreveu:
>
>  Hi!
>>
>
> Hi!
>
>
>
>> Caused by: java.lang.NullPointerException
>>        at $Request_12568a717d3.getSession($Request_12568a717d3.java)
>>        at $Request_12568a717a6.getSession($Request_12568a717a6.java)
>>        at
>> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)
>>
>
> It looks like the Request wasnt. Try getting the RequestGlobals service and
> invoking the storeServletRequestResponse() method before you use the
> ApplicationStateManager.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Exception accessing T5 Registry from other servlet

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 07 Dec 2009 08:31:44 -0200, Inge Solvoll <in...@gmail.com>  
escreveu:

> Hi!

Hi!

>
> Caused by: java.lang.NullPointerException
> 	at $Request_12568a717d3.getSession($Request_12568a717d3.java)
> 	at $Request_12568a717a6.getSession($Request_12568a717a6.java)
> 	at  
> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)

It looks like the Request wasnt. Try getting the RequestGlobals service  
and invoking the storeServletRequestResponse() method before you use the  
ApplicationStateManager.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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