You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Manuel Sugawara <ma...@gmail.com> on 2010/10/13 20:57:45 UTC

ApplicationStateManager throws an exception when an object is requested

Hi all,

Using tapestry 5.2.1. I have a filter that serves resources to clients
(images, documents, etc). This filter uses an injected service to check if
the user has the required permission to download the resource, but this is
not working as expected. The authorization filter throws an exception when
the following line is executed (full stack trace below):

    stateManager.getIfExists(Session.class);

where stateManager is an ApplicationStateManager instance. The filter is
build by the application module using:

    public static void
contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter>
configuration, @Autobuild FileFilter fileFilter) {
        configuration.add("FileFilter", fileFilter);
    }


The stack trace is:

java.lang.NullPointerException
at $Request_12ba6e8f229.getSession($Request_12ba6e8f229.java)
at $Request_12ba6e8f207.getSession($Request_12ba6e8f207.java)
at
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.exists(SessionApplicationStatePersistenceStrategy.java:80)
at
$ApplicationStatePersistenceStrategy_12ba6e8f228.exists($ApplicationStatePersistenceStrategy_12ba6e8f228.java)
at
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.exists(ApplicationStateManagerImpl.java:60)
at
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl.getIfExists(ApplicationStateManagerImpl.java:140)
at
$ApplicationStateManager_12ba6e8f226.getIfExists($ApplicationStateManager_12ba6e8f226.java)
at
mx.unam.xfc.auth.services.impl.SessionServiceImpl.authenticated(SessionServiceImpl.java:65)
at
$SessionService_12ba6e8f223.authenticated($SessionService_12ba6e8f223.java)
at
mx.unam.xfc.auth.services.impl.AuthorizationServiceImpl.authorized(AuthorizationServiceImpl.java:33)
at
$AuthorizationService_12ba6e8f21c.authorized($AuthorizationService_12ba6e8f21c.java)
at mx.unam.xfc.escuela.web.internal.FileFilter.service(FileFilter.java:89)
at
$HttpServletRequestHandler_12ba6e8f221.service($HttpServletRequestHandler_12ba6e8f221.java)
at
org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:915)
at
$HttpServletRequestHandler_12ba6e8f221.service($HttpServletRequestHandler_12ba6e8f221.java)
at
$HttpServletRequestHandler_12ba6e8f217.service($HttpServletRequestHandler_12ba6e8f217.java)
at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:147)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

Any idea what can be wrong?. If there are more details needed to debug this
please just let me know. Thanks in advance.

Regards,
Manuel.

Re: ApplicationStateManager throws an exception when an object is requested

Posted by Howard Lewis Ship <hl...@gmail.com>.
I already commited a fix that would generate a more useful message in
this situation.  I always think an NPE from inside Tapestry is a big
failure.

On Thu, Oct 14, 2010 at 9:25 AM, Manuel Sugawara
<ma...@gmail.com> wrote:
> On Wed, Oct 13, 2010 at 2:30 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
>
>> See https://issues.apache.org/jira/browse/TAP5-1304
>>
>> Basically, the Request service isn't set up yet in the method you are
>> invoking.
>>
>> Most likely, you want to contribute a filter to the RequestHandler
>> service pipeline, not the HttpServletRequestHandler pipeline.
>>
>
> Thank you Howard, that was helpful.
>
> Regards,
> Manuel.
>



-- 
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: ApplicationStateManager throws an exception when an object is requested

Posted by Manuel Sugawara <ma...@gmail.com>.
On Wed, Oct 13, 2010 at 2:30 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> See https://issues.apache.org/jira/browse/TAP5-1304
>
> Basically, the Request service isn't set up yet in the method you are
> invoking.
>
> Most likely, you want to contribute a filter to the RequestHandler
> service pipeline, not the HttpServletRequestHandler pipeline.
>

Thank you Howard, that was helpful.

Regards,
Manuel.

Re: ApplicationStateManager throws an exception when an object is requested

Posted by Howard Lewis Ship <hl...@gmail.com>.
See https://issues.apache.org/jira/browse/TAP5-1304

Basically, the Request service isn't set up yet in the method you are invoking.

Most likely, you want to contribute a filter to the RequestHandler
service pipeline, not the HttpServletRequestHandler pipeline.

On Wed, Oct 13, 2010 at 11:57 AM, Manuel Sugawara
<ma...@gmail.com> wrote:
> Hi all,
>
> Using tapestry 5.2.1. I have a filter that serves resources to clients
> (images, documents, etc). This filter uses an injected service to check if
> the user has the required permission to download the resource, but this is
> not working as expected. The authorization filter throws an exception when
> the following line is executed (full stack trace below):
>
>    stateManager.getIfExists(Session.class);
>
> where stateManager is an ApplicationStateManager instance. The filter is
> build by the application module using:
>
>    public static void
> contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter>
> configuration, @Autobuild FileFilter fileFilter) {
>        configuration.add("FileFilter", fileFilter);
>    }
>
>
> The stack trace is:
>
> java.lang.NullPointerException
> at $Request_12ba6e8f229.getSession($Request_12ba6e8f229.java)
> at $Request_12ba6e8f207.getSession($Request_12ba6e8f207.java)
> at
> org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.exists(SessionApplicationStatePersistenceStrategy.java:80)
> at
> $ApplicationStatePersistenceStrategy_12ba6e8f228.exists($ApplicationStatePersistenceStrategy_12ba6e8f228.java)
> at
> org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.exists(ApplicationStateManagerImpl.java:60)
> at
> org.apache.tapestry5.internal.services.ApplicationStateManagerImpl.getIfExists(ApplicationStateManagerImpl.java:140)
> at
> $ApplicationStateManager_12ba6e8f226.getIfExists($ApplicationStateManager_12ba6e8f226.java)
> at
> mx.unam.xfc.auth.services.impl.SessionServiceImpl.authenticated(SessionServiceImpl.java:65)
> at
> $SessionService_12ba6e8f223.authenticated($SessionService_12ba6e8f223.java)
> at
> mx.unam.xfc.auth.services.impl.AuthorizationServiceImpl.authorized(AuthorizationServiceImpl.java:33)
> at
> $AuthorizationService_12ba6e8f21c.authorized($AuthorizationService_12ba6e8f21c.java)
> at mx.unam.xfc.escuela.web.internal.FileFilter.service(FileFilter.java:89)
> at
> $HttpServletRequestHandler_12ba6e8f221.service($HttpServletRequestHandler_12ba6e8f221.java)
> at
> org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:915)
> at
> $HttpServletRequestHandler_12ba6e8f221.service($HttpServletRequestHandler_12ba6e8f221.java)
> at
> $HttpServletRequestHandler_12ba6e8f217.service($HttpServletRequestHandler_12ba6e8f217.java)
> at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:147)
> at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
> at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
> at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
> at
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at org.mortbay.jetty.Server.handle(Server.java:324)
> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
> at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
> at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
> at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
>
> Any idea what can be wrong?. If there are more details needed to debug this
> please just let me know. Thanks in advance.
>
> Regards,
> Manuel.
>



-- 
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