FacesFileNotFoundException bad Url

Splash Forums Rewrite Users FacesFileNotFoundException bad Url

This topic contains 5 replies, has 2 voices, and was last updated by  Christian Kaltepoth 2 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #25012

    youngreymond
    Participant

    Hello,

    I’m having a problem when the url is invalid or there is no resource.

    this is my configurationbuilder

    return ConfigurationBuilder.begin()
    
    				.addRule().when(Path.matches("/")).perform(Redirect.temporary(context.getContextPath() + "/web/home"))
    				.addRule().when(Path.matches("/web/")).perform(Redirect.temporary(context.getContextPath() + "/web/home"))
    				
    				.addRule(Join.path("/web/home").to("/portal/home.xhtml").withInboundCorrection())
    				.addRule(Join.path("/web/login").to("/portal/login.xhtml").withInboundCorrection())
    				
    				.addRule(Join.path("/web/{modulo}").to("/portal/home.xhtml").withInboundCorrection())
    				.perform(PhaseOperation.enqueue(new IgnorePostbackOperation(Invoke.binding(El.retrievalMethod("sessionBean.processModuloSeleccionado")))).after(PhaseId.RESTORE_VIEW))
    				.where("modulo").bindsTo(PhaseBinding.to(El.property("sessionBean.selectedModuloValue")).after(PhaseId.RESTORE_VIEW))
    				
    				.addRule(Join.path("/web/{modulo}/{servicio}").to("/portal/{modulo}/{servicio}.xhtml").withInboundCorrection())
    				
    		;
    
    	}

    when I type /web/modulo/somepage.xhtml, all is fine, but when I type /web/modulo/anynotfoundpage.xhtml I am getting a FacesFileNotFoundException.

    com.sun.faces.context.FacesFileNotFoundException: /portal/mantenimientos/modificar_usuariosf.xhtml Not Found in ExternalContext as a Resource
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:232)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:273)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:209)
    at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:114)
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:233)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    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.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    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:199)
    …..

    are there any way to send a 404 error when the resource is not found ?

    #25015

    Isn’t this default behavior with JSF? So this isn’t an issue caused by Rewrite, right? So you are asking if Rewrite can work around this default behavior of JSF?

    #25016

    youngreymond
    Participant

    Sorry, I know this is the default behavior of JSF. The question will be there are any way to handle this with Rewrite?, please see my last question on first post. Sorry for my bad english.

    #25017

    Thanks for the clarification. Yeah, you can do something like this with Rewrite. Something like this:

    .addRule()
    .when(Direction.isInbound()
        .and(Path.matches("/{something}.xhtml"))
        .and(Resource.notExists("/{something}.xhtml")))
    .perform(SendStatus.code(404))
    .where("something").matches(".*")
    

    I didn’t test it but it shows how I would do it. 🙂

    #25021

    youngreymond
    Participant

    Hi, thanks for the info, but which version of Rewrite are you using, Resource.notExists method is not available on 2.0.7-final

    #25023

    Oh, sorry. My fault. There is no ‘notExists’ but only a ‘exists’. So please try this one:

    .addRule()
    .when(Direction.isInbound()
        .and(Path.matches("/{something}.xhtml"))
        .and(Not.any(Resource.exists("/{something}.xhtml"))))
    .perform(SendStatus.code(404))
    .where("something").matches(".*")
    
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Comments are closed.