Empty page on ValidatiorException instead of 404 page

Splash Forums PrettyFaces Users Empty page on ValidatiorException instead of 404 page

This topic contains 18 replies, has 3 voices, and was last updated by  Lincoln Baxter III 3 years, 1 month ago.

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #23791

    hendrik
    Participant

    Hi,

    i’m getting an empty page instead of the 404 error page when my validtor throws a ValidatorException. However i get the correct 404 page if i enter a wrong path on my domain, e.g. localhost:8080/some/path/that/leads/to/nerverland, where some won’t through the ValidatorException because the validation was successful, but the path leads to no ressource.

    Relevant code snippets:

    pretty-config`
    <pattern value=”/#{ /([a-zA-Z0-9]{3}[a-zA-Z0-9]*)/ myBean.path }” >
    <validate index=”0″ validator=”#{myBean.checkPath}” />
    </pattern>

    
    
    myBean.java

    // gets called, ValidatorException will be thrown.
    public void checkPath(FacesContext context, UIComponent component, Object value) {
    if(this.someBoundary.findSomethingByPath(value.toString()) == null) {
    throw new ValidatorException(new FacesMessage(“404”));
    }
    }

    
    
    web.xml

    <filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
    <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
    <dispatcher>ASYNC</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <error-page>
    <error-code>404</error-code>
    <location>/fs/errors/404.xhtml</location>
    </error-page>
    `

    Result: an empty page, but i want my standard 404.xhtml. Any ideas?

    EDIT: Firefox developer console shows a 404 response, so something is working, but i only have the empty page.

    • This topic was modified 3 years, 2 months ago by  hendrik.
    • This topic was modified 3 years, 2 months ago by  hendrik.
    #23794

    Hey,

    could you explain “empty page” a bit more? I understand that the browser displays just a white page, but what about the HTML source? Is also empty?

    Could you also try to use a simple HTML page as the 404 page instead of a JSF page. Something like this:

    <error-page>
      <error-code>404</error-code>
      <location>/404.html</location>
    </error-page>

    With something like this in error.html:

    <html>
    <body>
    <h1>Error</h1>
    </body>
    </html>
    #23800

    hendrik
    Participant

    Hey,

    could you explain “empty page” a bit more? I understand that the browser displays just a white page, but what about the HTML source? Is also empty?

    Source is empty, too.

    I tested your minimal error page, no difference to my jsf page: the page renders for all 404 responses except the one triggered by the ValidatorException. Could that be a path issue? /fs is my faces servlet, all error pages are in /fs/errors:

    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/fs/*</url-pattern>
    </servlet-mapping>

    #23830

    I’m not sure what is causing this issue. Could you perhaps create a minimal sample app to reproduce it? This would help us to find the root cause of this.

    #23896

    hendrik
    Participant

    I’m not sure what is causing this issue. Could you perhaps create a minimal sample app to reproduce it? This would help us to find the root cause of this.

    Well i’m trying but my validator never gets called in my minimal reproducer app and i get the empty page in Firefox. Google Chrome gives me an “Oops! This link appears to be broken.” page instead of the empty page. Note that the validator is called in my actual application, i can set single step through the whole method and can write to the log, but not in my reproducer app.

    #23897

    Which HTTP response code do you get?

    #23898

    hendrik
    Participant

    Which HTTP response code do you get?

    Well it’s a 404, but i noticed a subtle difference(according to Firefox Web Console):

    404 error when the error page get’s rendered: HTTP/1.1 404
    404 error from validator (doesn’t matter it it get’s called or not): HTTP/1.1 404 Not Found

    Don’t now if that should make a difference.

    EDIT: Got the reproducer working now, see the attachement. http://localhost:8080/PrettyFacesTest/error should give you the broken page, if the regex doesn’t match you will get the proper 404 page and everything else should bring you to the home page.

    • This reply was modified 3 years, 2 months ago by  hendrik.
    #23901

    Ok, great. I’ll have a look at the project as soon as I find some time. Hopefully soon. 🙂

    Which container did you use?

    #23902

    hendrik
    Participant

    I’m on Glassfish 3.1.2, JSF 2.1, JavaEE 6, project was created with NetBeans 7.3.

    #23905

    Hey,

    I spent a few hours to debug this issue. Your sample app helped a lot to find the root cause of this. Thanks for that.

    I created a ticket to track this. The issue contains a description of my findings:

    https://github.com/ocpsoft/rewrite/issues/96

    I hope I’ll find some time in the next days to fix this issue.

    But please note that we won’t be able to fix this issue in the PrettyFaces 3.3.x code any more. There is no more active development happening for PrettyFaces 3.3.x. Rewrite is the successor of PrettyFaces. Rewrite offers a PrettyFaces compatibility module. So you can migrate to Rewrite without changing your application code.

    Unfortunately while testing your sample app with the Rewrite PrettyFaces module, I ran into another issue:

    https://github.com/ocpsoft/rewrite/issues/95

    We will do our best to fix these issues soon. 🙂

    #23923

    hendrik
    Participant

    Unfortunately while testing your sample app with the Rewrite PrettyFaces module, I ran into another issue:

    https://github.com/ocpsoft/rewrite/issues/95

    Totoally forget to mention this one, that was the reason for commenting out the rewrite dependencies in the POM. Glad you could reproduce the issues.

    #23924

    I think both issues should be easy to fix. I hope. 🙂

    #24149

    hendrik
    Participant

    I think both issues should be easy to fix. I hope. 🙂

    Upgraded to Rewrite 2.0.2.Final after lurking around on github and seeing the release, everything works now, both issues are fixed :).
    If only Oracle would fix Java security holes as fast as you guys fix your code. God job.

    #24152

    Thanks for letting us know that you got this working! It’s always great to hear things work out. And yeah 😉 Frequent minor releases are important for everyone. Thanks for the compliments!

    #24243

    hendrik
    Participant

    Sadly during testing a new problem arised: Our error pages mapped to exceptions stopped working, all i can see is a stack trace with a rewrite exception wrapping other exceptions, for example:

    WARNING: StandardWrapperValve[default]: PWC1406: Servlet.service() for servlet default threw exception
    org.ocpsoft.rewrite.exception.RewriteException: Error handling Rewrite result
    	at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:72)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:255)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:186)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    	at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    	at java.lang.Thread.run(Thread.java:722)
    Caused by: javax.servlet.ServletException: javax.ejb.EJBAccessException
    	at org.omnifaces.filter.FacesExceptionFilter.doFilter(FacesExceptionFilter.java:62)
    	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:75)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	at org.omnifaces.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:115)
    	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:75)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	at net.psw.console.servlet.filter.RememberMeFilter.doFilter(RememberMeFilter.java:94)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:191)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:191)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:807)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:505)
    	at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:476)
    	at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:355)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:305)
    	at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:40)
    	... 27 more
    Caused by: javax.ejb.EJBAccessException
    	at com.sun.ejb.containers.BaseContainer.mapLocal3xException(BaseContainer.java:2323)
    	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2096)
    	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
    	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
    	at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
    	at com.sun.proxy.$Proxy371.findCurrentAccount(Unknown Source)
    	at net.psw.console.faces.environment.CurrentAccountProducer.getCurrentAccount(CurrentAccountProducer.java:31)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:601)
    	at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
    	at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    	at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
    	at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
    	at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
    	at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:137)
    	at org.jboss.weld.bean.ProducerMethod$ProducerMethodProducer.produce(ProducerMethod.java:136)
    	at org.jboss.weld.bean.AbstractProducerBean$AbstractProducer.produce(AbstractProducerBean.java:319)
    	at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:307)
    	at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:107)
    	at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)
    	at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
    	at net.psw.console.accountmgmt.entity.Account$Proxy$_$$_WeldClientProxy.getName(Account$Proxy$_$$_WeldClientProxy.java)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:601)
    	at javax.el.BeanELResolver.getValue(BeanELResolver.java:363)
    	at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    	at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    	at com.sun.el.parser.AstValue.getValue(AstValue.java:138)
    	at com.sun.el.parser.AstValue.getValue(AstValue.java:183)
    	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224)
    	at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
    	at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:227)
    	at com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:150)
    	at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85)
    	at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    	at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:203)
    	at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:875)
    	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
    	at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
    	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:875)
    	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:439)
    	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
    	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
    	at org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:186)
    	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
    	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	at org.omnifaces.filter.FacesExceptionFilter.doFilter(FacesExceptionFilter.java:56)
    	... 53 more
    Caused by: javax.ejb.AccessLocalException: Client not authorized for this invocation
    	at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1888)
    	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    	... 110 more

    while i should get my AccessDeniedError.xhtml:

    <error-page>
            <exception-type>javax.ejb.EJBAccessException</exception-type>
            <location>/fs/errors/AccessDeniedError.xhtml</location>
        </error-page>

    Note that it used to work with the prettyfaces filter, but not with the rewrite filter which should configure itself automatically. Do i miss something? There isn’t really much documentation on the rewrite filter.

    • This reply was modified 3 years, 1 month ago by  hendrik.
    • This reply was modified 3 years, 1 month ago by  hendrik.
    • This reply was modified 3 years, 1 month ago by  hendrik.
Viewing 15 posts - 1 through 15 (of 19 total)

You must be logged in to reply to this topic.

Comments are closed.