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 <hls...@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 <inge.tapes...@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 <hls...@gmail.com>
> wrote:
> >
> >> On Mon, Dec 7, 2009 at 7:11 AM, Inge Solvoll <inge.tapes...@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.tapes...@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 <
> >> >> thiag...@gmail.com> wrote:
> >> >>
> >> >>> Em Mon, 07 Dec 2009 08:31:44 -0200, Inge Solvoll <
> >> inge.tapes...@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-unsubscr...@tapestry.apache.org
> >> >>> For additional commands, e-mail: users-h...@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-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@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-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to