[ 
https://issues.apache.org/jira/browse/TAP5-257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12641829#action_12641829
 ] 

Ulrich Stärk commented on TAP5-257:
-----------------------------------

I am still getting an exception. I am contributing a HttpServletRequestFilter 
to the HttpServletRequestFilterHandler service. This filter processes OpenID 
authentication and delegates to another service to look up the user. I am 
decorating this lookup service in order to store the return value as an ASO. In 
my decorator I inject the applicationStateManager and call 
applicationStateManager.set(...), but all I get is the following exception:

java.lang.NullPointerException
        at $Request_11d24c24553.getSession($Request_11d24c24553.java)
        at $Request_11d24c24518.getSession($Request_11d24c24518.java)
        at 
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:47)
        at 
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.set(SessionApplicationStatePersistenceStrategy.java:88)
        at 
$ApplicationStatePersistenceStrategy_11d24c2460b.set($ApplicationStatePersistenceStrategy_11d24c2460b.java)
        at 
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.set(ApplicationStateManagerImpl.java:50)
        at 
org.apache.tapestry5.internal.services.ApplicationStateManagerImpl.set(ApplicationStateManagerImpl.java:138)
        at 
$ApplicationStateManager_11d24c24569.set($ApplicationStateManager_11d24c24569.java)
        at 
de.spielviel.mailadmin.services.impl.UserDetailsDecoratorImpl$1.advise(UserDetailsDecoratorImpl.java:43)
        at 
org.apache.tapestry5.ioc.internal.services.AbstractInvocation.proceed(AbstractInvocation.java:121)
        at 
$UserDetailsService_11d24c24608.loadUserByUsername($UserDetailsService_11d24c24608.java)
        at 
$UserDetailsService_11d24c24534.loadUserByUsername($UserDetailsService_11d24c24534.java)
        at 
org.springframework.security.providers.openid.OpenIDAuthenticationProvider.authenticate(OpenIDAuthenticationProvider.java:70)
        at 
org.springframework.security.providers.ProviderManager.doAuthentication(ProviderManager.java:195)
        at 
org.springframework.security.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:46)
        at 
$AuthenticationManager_11d24c24509.authenticate($AuthenticationManager_11d24c24509.java)
        at 
org.springframework.security.ui.openid.OpenIDAuthenticationProcessingFilter.attemptAuthentication(OpenIDAuthenticationProcessingFilter.java:84)
        at 
org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:252)
        at 
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at 
nu.localhost.tapestry5.springsecurity.services.internal.HttpServletRequestFilterWrapper.service(HttpServletRequestFilterWrapper.java:52)
        at 
$HttpServletRequestFilter_11d24c24531.service($HttpServletRequestFilter_11d24c24531.java)
        at 
$HttpServletRequestHandler_11d24c24533.service($HttpServletRequestHandler_11d24c24533.java)
        at 
nu.localhost.tapestry5.springsecurity.services.internal.HttpServletRequestFilterWrapper$1.doFilter(HttpServletRequestFilterWrapper.java:56)
        at 
org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
        at 
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at 
nu.localhost.tapestry5.springsecurity.services.internal.HttpServletRequestFilterWrapper.service(HttpServletRequestFilterWrapper.java:52)
        at 
$HttpServletRequestFilter_11d24c24529.service($HttpServletRequestFilter_11d24c24529.java)
        at 
$HttpServletRequestHandler_11d24c24533.service($HttpServletRequestHandler_11d24c24533.java)
        at 
$HttpServletRequestHandler_11d24c24528.service($HttpServletRequestHandler_11d24c24528.java)
        at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:179)
        at 
org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
        at 
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
        at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
        at 
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
        at org.mortbay.http.HttpServer.service(HttpServer.java:909)
        at org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
        at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
        at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
        at 
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245)
        at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
        at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)

> NPE in RequestFilter if ApplicationStateManager is used
> -------------------------------------------------------
>
>                 Key: TAP5-257
>                 URL: https://issues.apache.org/jira/browse/TAP5-257
>             Project: Tapestry 5
>          Issue Type: Bug
>            Reporter: Francois Armand
>            Assignee: Howard M. Lewis Ship
>             Fix For: 5.0.16
>
>
> If one builds a request filter that use ApplicationStateManager, a call to 
> any intersting method of the ASM throws an NPE.
> The problem is that the ApplicationStateManager use the session as default 
> storage strategy, and that he tries to take it trough the 
> RequesGlobals#getRequest that returns null in the request handler. 
> It's an expected behavior since the RequestGlobals#storeRequestResponse 
> method is called in the *terminator* of the RequestFilter pipeline. Perhpas 
> there is a good reason to do it so, and not in the head of the pipeline, but 
> I don't see it.
> Notice: it's exactly the same thing for HttpRequest/HttpResponse and 
> HttpServletRequestHandler and storeServletRequestResponse
> Workaround : contribute a RequestFilter before any other whose sole action is 
> to set Request/Response:
> public static RequestFilter buildSetRequestResponse(final RequestGlobals 
> requestGlobals) {
>       return new RequestFilter(){
>               public boolean service(Request request, Response response, 
> RequestHandler handler) throws IOException {
>                       requestGlobals.storeRequestResponse(request, response);
>                       return handler.service(request, response);
>               }
>       };
> }
> public static void 
> contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
>               @InjectService("setRequestResponse") RequestFilter 
> setRequestResponse,
>               ...other filters...) {
>               configuration.add("setRequestResponse", setRequestResponse, 
> "before:*");
>               ...other configurations...
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to