Re: Request Filter with ApplicationStateManager
Hi Richard, Thanks a lot for your response! on your first point, I have tried this with no luck... so your second observation may be more likely, although the documentation just leaves me with more questions, i'm not convinced that the state manager should ever turn up null, but it's not a big deal I will simply avoid the RequestFilter. Thanks again, Peter Richard Kirby wrote: Hi Peter, My guess is that for a RequestFilter, you need to ensure that your filter is contributed after the default Tap5 filter that wires up the HttpServletRequest object to the Tap5 Request object (which is what is causing the NPE). However, I think on reading the RequestHandler pipeline section of http://tapestry.apache.org/tapestry5/tapestry-core/guide/request.html that this is probably done as the final step in the pipeline (ie the terminator) before passing onto the MasterDispatcher service that processes the Dispatcher pipeline. In other words, you can't do what you want to do. Not done any Tap5 coding yet so I may be wrong but hopefully I have given you a pointer. Cheers Richard Peter Stavrinides wrote: Hi, Perhaps I haven't phrased this question quite right since I didn't get a response... Let me try it again. What I have is two contributions, a RequestFilter and a Dispatcher (the code is just about identicle) both services have a dependancy on the ApplicationStateManager, so I wire it by injecting it via the constructor: //contribution public void contributeMasterDispatcher(OrderedConfigurationDispatcher configuration, @InjectService(AccessController) Dispatcher accessController) { configuration.add(AccessController, accessController, before:PageRender); } //constructor public AccessController(ApplicationStateManager asm){ this.asm_ = asm; } The Dispatcher seems to work perfectly, this simple test: if(asm_.exists(UserAsoObject.class)) returns true/false, my state manager is working, however for the RequestFilter, with virtually identical code, the same test returns a NPE instead. I just wan't to understand where I am going wrong. Thanks again, Peter Peter Stavrinides wrote: Hi All, I can get hold of the ApplicationStateManager using the Dispatcher interface without a problem, however the same code fails using the Tapestry RequestFilter interface? specifically *if(asm_.exists(**UserAsoObject.class)**)) *returns a NPE. Would this be a bug or shouldn't I be using it here in this way? public class AccessController implements RequestFilter { /* Our state manager. */ private ApplicationStateManager asm_; public AccessController(ApplicationStateManager asm){ this.asm_ = asm; } @Override public boolean service(Request request, Response response, RequestHandler handler) throws IOException { *if(asm_.exists(UserAsoObject.class)) {* UserAsoObject userObject = asm_.get(UserAsoObject.class); } return handler.service(request,response); } produced the following stack trace: java.lang.NullPointerException at $Request_116a49796f3.getContextPath($Request_116a49796f3.java) at $Request_116a49796d5.getContextPath($Request_116a49796d5.java) at org.apache.tapestry.internal.services.ClasspathAssetAliasManagerImpl.toClientURL(ClasspathAssetAliasManagerImpl.java:90) at $ClasspathAssetAliasManager_116a4979724.toClientURL($ClasspathAssetAliasManager_116a4979724.java) at org.apache.tapestry.internal.services.ClasspathAssetFactory.buildClientURL(ClasspathAssetFactory.java:84) at org.apache.tapestry.internal.services.ClasspathAssetFactory.clientURL(ClasspathAssetFactory.java:59) at org.apache.tapestry.internal.services.ClasspathAssetFactory.access$000(ClasspathAssetFactory.java:33) at org.apache.tapestry.internal.services.ClasspathAssetFactory$1.toClientURL(ClasspathAssetFactory.java:102) at org.apache.tapestry.internal.services.PageRenderSupportImpl.addStylesheetLink(PageRenderSupportImpl.java:109) at org.apache.tapestry.services.TapestryModule$17.renderMarkup(TapestryModule.java:1322) at $MarkupRenderer_116a4979727.renderMarkup($MarkupRenderer_116a4979727.java) at org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:64) at $PageMarkupRenderer_116a497971d.renderPageMarkup($PageMarkupRenderer_116a497971d.java) at org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:56) at $PageResponseRenderer_116a49796f4.renderPageResponse($PageResponseRenderer_116a49796f4.java) at org.apache.tapestry.internal.services.DefaultRequestExceptionHandler.handleRequestException(DefaultRequestExceptionHandler.java:60) at
Re: Request Filter with ApplicationStateManager
I think, at the very least, we need to handle the null case better, with a message that explains what property of what object/service is null. Further, it's looking like the current approach is a little heavy-handed; perhaps the Request and Response objects should be created earlier and stored into the RequestGlobals service; the Request/Response at the end of the pipeline can be re-stored into the RG in case one of the filters overrode it (such as, when a multipart form submission request arrives). On Dec 5, 2007 2:10 AM, Richard Kirby [EMAIL PROTECTED] wrote: Hi Peter, My guess is that for a RequestFilter, you need to ensure that your filter is contributed after the default Tap5 filter that wires up the HttpServletRequest object to the Tap5 Request object (which is what is causing the NPE). However, I think on reading the RequestHandler pipeline section of http://tapestry.apache.org/tapestry5/tapestry-core/guide/request.html that this is probably done as the final step in the pipeline (ie the terminator) before passing onto the MasterDispatcher service that processes the Dispatcher pipeline. In other words, you can't do what you want to do. Not done any Tap5 coding yet so I may be wrong but hopefully I have given you a pointer. Cheers Richard Peter Stavrinides wrote: Hi, Perhaps I haven't phrased this question quite right since I didn't get a response... Let me try it again. What I have is two contributions, a RequestFilter and a Dispatcher (the code is just about identicle) both services have a dependancy on the ApplicationStateManager, so I wire it by injecting it via the constructor: //contribution public void contributeMasterDispatcher(OrderedConfigurationDispatcher configuration, @InjectService(AccessController) Dispatcher accessController) { configuration.add(AccessController, accessController, before:PageRender); } //constructor public AccessController(ApplicationStateManager asm){ this.asm_ = asm; } The Dispatcher seems to work perfectly, this simple test: if(asm_.exists(UserAsoObject.class)) returns true/false, my state manager is working, however for the RequestFilter, with virtually identical code, the same test returns a NPE instead. I just wan't to understand where I am going wrong. Thanks again, Peter Peter Stavrinides wrote: Hi All, I can get hold of the ApplicationStateManager using the Dispatcher interface without a problem, however the same code fails using the Tapestry RequestFilter interface? specifically *if(asm_.exists(**UserAsoObject.class)**)) *returns a NPE. Would this be a bug or shouldn't I be using it here in this way? public class AccessController implements RequestFilter { /* Our state manager. */ private ApplicationStateManager asm_; public AccessController(ApplicationStateManager asm){ this.asm_ = asm; } @Override public boolean service(Request request, Response response, RequestHandler handler) throws IOException { *if(asm_.exists(UserAsoObject.class)) {* UserAsoObject userObject = asm_.get(UserAsoObject.class); } return handler.service(request,response); } produced the following stack trace: java.lang.NullPointerException at $Request_116a49796f3.getContextPath($Request_116a49796f3.java) at $Request_116a49796d5.getContextPath($Request_116a49796d5.java) at org.apache.tapestry.internal.services.ClasspathAssetAliasManagerImpl.toClientURL(ClasspathAssetAliasManagerImpl.java:90) at $ClasspathAssetAliasManager_116a4979724.toClientURL($ClasspathAssetAliasManager_116a4979724.java) at org.apache.tapestry.internal.services.ClasspathAssetFactory.buildClientURL(ClasspathAssetFactory.java:84) at org.apache.tapestry.internal.services.ClasspathAssetFactory.clientURL(ClasspathAssetFactory.java:59) at org.apache.tapestry.internal.services.ClasspathAssetFactory.access$000(ClasspathAssetFactory.java:33) at org.apache.tapestry.internal.services.ClasspathAssetFactory$1.toClientURL(ClasspathAssetFactory.java:102) at org.apache.tapestry.internal.services.PageRenderSupportImpl.addStylesheetLink(PageRenderSupportImpl.java:109) at org.apache.tapestry.services.TapestryModule$17.renderMarkup(TapestryModule.java:1322) at $MarkupRenderer_116a4979727.renderMarkup($MarkupRenderer_116a4979727.java) at org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:64) at $PageMarkupRenderer_116a497971d.renderPageMarkup($PageMarkupRenderer_116a497971d.java) at org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:56) at
Re: Request Filter with ApplicationStateManager
Hi Peter, My guess is that for a RequestFilter, you need to ensure that your filter is contributed after the default Tap5 filter that wires up the HttpServletRequest object to the Tap5 Request object (which is what is causing the NPE). However, I think on reading the RequestHandler pipeline section of http://tapestry.apache.org/tapestry5/tapestry-core/guide/request.html that this is probably done as the final step in the pipeline (ie the terminator) before passing onto the MasterDispatcher service that processes the Dispatcher pipeline. In other words, you can't do what you want to do. Not done any Tap5 coding yet so I may be wrong but hopefully I have given you a pointer. Cheers Richard Peter Stavrinides wrote: Hi, Perhaps I haven't phrased this question quite right since I didn't get a response... Let me try it again. What I have is two contributions, a RequestFilter and a Dispatcher (the code is just about identicle) both services have a dependancy on the ApplicationStateManager, so I wire it by injecting it via the constructor: //contribution public void contributeMasterDispatcher(OrderedConfigurationDispatcher configuration, @InjectService(AccessController) Dispatcher accessController) { configuration.add(AccessController, accessController, before:PageRender); } //constructor public AccessController(ApplicationStateManager asm){ this.asm_ = asm; } The Dispatcher seems to work perfectly, this simple test: if(asm_.exists(UserAsoObject.class)) returns true/false, my state manager is working, however for the RequestFilter, with virtually identical code, the same test returns a NPE instead. I just wan't to understand where I am going wrong. Thanks again, Peter Peter Stavrinides wrote: Hi All, I can get hold of the ApplicationStateManager using the Dispatcher interface without a problem, however the same code fails using the Tapestry RequestFilter interface? specifically *if(asm_.exists(**UserAsoObject.class)**)) *returns a NPE. Would this be a bug or shouldn't I be using it here in this way? public class AccessController implements RequestFilter { /* Our state manager. */ private ApplicationStateManager asm_; public AccessController(ApplicationStateManager asm){ this.asm_ = asm; } @Override public boolean service(Request request, Response response, RequestHandler handler) throws IOException { *if(asm_.exists(UserAsoObject.class)) {* UserAsoObject userObject = asm_.get(UserAsoObject.class); } return handler.service(request,response); } produced the following stack trace: java.lang.NullPointerException at $Request_116a49796f3.getContextPath($Request_116a49796f3.java) at $Request_116a49796d5.getContextPath($Request_116a49796d5.java) at org.apache.tapestry.internal.services.ClasspathAssetAliasManagerImpl.toClientURL(ClasspathAssetAliasManagerImpl.java:90) at $ClasspathAssetAliasManager_116a4979724.toClientURL($ClasspathAssetAliasManager_116a4979724.java) at org.apache.tapestry.internal.services.ClasspathAssetFactory.buildClientURL(ClasspathAssetFactory.java:84) at org.apache.tapestry.internal.services.ClasspathAssetFactory.clientURL(ClasspathAssetFactory.java:59) at org.apache.tapestry.internal.services.ClasspathAssetFactory.access$000(ClasspathAssetFactory.java:33) at org.apache.tapestry.internal.services.ClasspathAssetFactory$1.toClientURL(ClasspathAssetFactory.java:102) at org.apache.tapestry.internal.services.PageRenderSupportImpl.addStylesheetLink(PageRenderSupportImpl.java:109) at org.apache.tapestry.services.TapestryModule$17.renderMarkup(TapestryModule.java:1322) at $MarkupRenderer_116a4979727.renderMarkup($MarkupRenderer_116a4979727.java) at org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:64) at $PageMarkupRenderer_116a497971d.renderPageMarkup($PageMarkupRenderer_116a497971d.java) at org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:56) at $PageResponseRenderer_116a49796f4.renderPageResponse($PageResponseRenderer_116a49796f4.java) at org.apache.tapestry.internal.services.DefaultRequestExceptionHandler.handleRequestException(DefaultRequestExceptionHandler.java:60) at $RequestExceptionHandler_116a49796e7.handleRequestException($RequestExceptionHandler_116a49796e7.java) at org.apache.tapestry.services.TapestryModule$2.service(TapestryModule.java:536) at $RequestHandler_116a49796ec.service($RequestHandler_116a49796ec.java) at org.apache.tapestry.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_116a49796ec.service($RequestHandler_116a49796ec.java) at
Re: Request Filter with ApplicationStateManager
Hi, Perhaps I haven't phrased this question quite right since I didn't get a response... Let me try it again. What I have is two contributions, a RequestFilter and a Dispatcher (the code is just about identicle) both services have a dependancy on the ApplicationStateManager, so I wire it by injecting it via the constructor: //contribution public void contributeMasterDispatcher(OrderedConfigurationDispatcher configuration, @InjectService(AccessController) Dispatcher accessController) { configuration.add(AccessController, accessController, before:PageRender); } //constructor public AccessController(ApplicationStateManager asm){ this.asm_ = asm; } The Dispatcher seems to work perfectly, this simple test: if(asm_.exists(UserAsoObject.class)) returns true/false, my state manager is working, however for the RequestFilter, with virtually identical code, the same test returns a NPE instead. I just wan't to understand where I am going wrong. Thanks again, Peter Peter Stavrinides wrote: Hi All, I can get hold of the ApplicationStateManager using the Dispatcher interface without a problem, however the same code fails using the Tapestry RequestFilter interface? specifically *if(asm_.exists(**UserAsoObject.class)**)) *returns a NPE. Would this be a bug or shouldn't I be using it here in this way? public class AccessController implements RequestFilter { /* Our state manager. */ private ApplicationStateManager asm_; public AccessController(ApplicationStateManager asm){ this.asm_ = asm; } @Override public boolean service(Request request, Response response, RequestHandler handler) throws IOException { *if(asm_.exists(UserAsoObject.class)) {* UserAsoObject userObject = asm_.get(UserAsoObject.class); } return handler.service(request,response); } produced the following stack trace: java.lang.NullPointerException at $Request_116a49796f3.getContextPath($Request_116a49796f3.java) at $Request_116a49796d5.getContextPath($Request_116a49796d5.java) at org.apache.tapestry.internal.services.ClasspathAssetAliasManagerImpl.toClientURL(ClasspathAssetAliasManagerImpl.java:90) at $ClasspathAssetAliasManager_116a4979724.toClientURL($ClasspathAssetAliasManager_116a4979724.java) at org.apache.tapestry.internal.services.ClasspathAssetFactory.buildClientURL(ClasspathAssetFactory.java:84) at org.apache.tapestry.internal.services.ClasspathAssetFactory.clientURL(ClasspathAssetFactory.java:59) at org.apache.tapestry.internal.services.ClasspathAssetFactory.access$000(ClasspathAssetFactory.java:33) at org.apache.tapestry.internal.services.ClasspathAssetFactory$1.toClientURL(ClasspathAssetFactory.java:102) at org.apache.tapestry.internal.services.PageRenderSupportImpl.addStylesheetLink(PageRenderSupportImpl.java:109) at org.apache.tapestry.services.TapestryModule$17.renderMarkup(TapestryModule.java:1322) at $MarkupRenderer_116a4979727.renderMarkup($MarkupRenderer_116a4979727.java) at org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:64) at $PageMarkupRenderer_116a497971d.renderPageMarkup($PageMarkupRenderer_116a497971d.java) at org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:56) at $PageResponseRenderer_116a49796f4.renderPageResponse($PageResponseRenderer_116a49796f4.java) at org.apache.tapestry.internal.services.DefaultRequestExceptionHandler.handleRequestException(DefaultRequestExceptionHandler.java:60) at $RequestExceptionHandler_116a49796e7.handleRequestException($RequestExceptionHandler_116a49796e7.java) at org.apache.tapestry.services.TapestryModule$2.service(TapestryModule.java:536) at $RequestHandler_116a49796ec.service($RequestHandler_116a49796ec.java) at org.apache.tapestry.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_116a49796ec.service($RequestHandler_116a49796ec.java) at org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:94) at org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:85) at org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:77) at org.apache.tapestry.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:107) at $RequestHandler_116a49796ec.service($RequestHandler_116a49796ec.java) at $RequestHandler_116a49796e4.service($RequestHandler_116a49796e4.java) at org.apache.tapestry.services.TapestryModule$11.service(TapestryModule.java:921) at