Re: URL rewriting with PrettyFaces, URLMapping and pretty:link

Splash Forums PrettyFaces Users URL rewriting with PrettyFaces, URLMapping and pretty:link Re: URL rewriting with PrettyFaces, URLMapping and pretty:link

#22899

balteo
Participant

I have implemented the following configuration:

`@Override

public Configuration getConfiguration(ServletContext context) {

log.debug(“getConfiguration”);

return ConfigurationBuilder.begin()

.addRule(Join.path(“/lang/en/gallery”).to(“/lang/en/galerie”).withInboundCorrection())

.addRule(Join.path(“/lang/en/biography”).to(“/lang/en/biographie”).withInboundCorrection())

.addRule(Join.path(“/lang/en/newsletter-registration”).to(“/lang/en/inscription-newsletter”).withInboundCorrection())

.addRule(Join.path(“/lang/en/contact”).to(“/lang/en/contact”).withInboundCorrection())//HERE

.addRule(Join.path(“/lang/en/works-made-to-order”).to(“/lang/en/commandes-personnalisees”).withInboundCorrection())

.addRule(Join.path(“/lang/en/links”).to(“/lang/en/liens”).withInboundCorrection());

}`

Unfortunately, the line marked //HERE throws an exception (see below). It seems that it does not like the fact that the rule maps the same URLs… Unfortunately, the English for “contact” is the same as the French for “contact”…

If I remove the rule, the same error occurs.

23 août 2012 20:47:31 com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
GRAVE: Error Rendering View[/contact.xhtml]
java.lang.NullPointerException
at org.ocpsoft.rewrite.servlet.config.Path.evaluateHttp(Path.java:101)
at org.ocpsoft.rewrite.servlet.config.HttpCondition.evaluate(HttpCondition.java:41)
at org.ocpsoft.rewrite.servlet.config.rule.Join.evaluate(Join.java:139)
at org.ocpsoft.rewrite.config.And.evaluate(And.java:55)
at org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:101)
at org.ocpsoft.rewrite.config.And.evaluate(And.java:55)
at org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:101)
at org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider.rewriteHttp(DefaultHttpRewriteProvider.java:62)
at org.ocpsoft.rewrite.servlet.http.HttpRewriteProvider.rewrite(HttpRewriteProvider.java:44)
at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedResponse.rewrite(HttpRewriteWrappedResponse.java:288)
at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedResponse.encodeURL(HttpRewriteWrappedResponse.java:264)
at com.sun.faces.context.ExternalContextImpl.encodeActionURL(ExternalContextImpl.java:514)
at javax.faces.context.ExternalContextWrapper.encodeActionURL(ExternalContextWrapper.java:104)
at com.sun.faces.renderkit.html_basic.FormRenderer.getActionStr(FormRenderer.java:235)
at com.sun.faces.renderkit.html_basic.FormRenderer.encodeBegin(FormRenderer.java:135)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1777)
at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)
at org.richfaces.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:57)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)
at org.richfaces.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:57)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
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:424)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:163)
at org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:151)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:182)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:690)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:477)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:137)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
̀