Rewrite + JSF 2.2: the backing bean method is called twice

Splash Forums Rewrite Users Rewrite + JSF 2.2: the backing bean method is called twice


This topic contains 17 replies, has 3 voices, and was last updated by  Lincoln Baxter III 7 years, 9 months ago.

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
  • #26017


    Hello everyone:

    First, sorry for my english.
    I just started using Rewrite and I made a simple test project. I have a view(Menu.xhtml) that has a link to About.xhtml, when clicking on the link invokes a method of the backing bean, but this method is called twice. I don’t know why this happening.
    My project is attached, just need to add JSF 2.2 (Mojarra) library

    I appreciate your help, thank you very much


    I just deployed your app to Wildfly and everything works fine. The “init” method is only called once.

    In such cases I typically add a Thread.dumpStack(); to the corresponding method. The stacktrace will tell you how is calling the method.




    Thank you very much for your reply. I added Thread.dumpStack();to init and shows me the following:

    java.lang.Exception: Stack trace
    	at java.lang.Thread.dumpStack(
    	at urlrewrite.action.AboutAction.init(
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    	at java.lang.reflect.Method.invoke(
    	at org.apache.el.parser.AstValue.invoke(
    	at org.apache.el.MethodExpressionImpl.invoke(
    	at org.ocpsoft.rewrite.faces.FacesExpressionLanguageProvider.evaluateMethodExpression(
    	at org.ocpsoft.rewrite.faces.FacesExpressionLanguageProvider.evaluateMethodExpression(
    	at org.ocpsoft.rewrite.el.El$ElMethod$
    	at org.ocpsoft.rewrite.el.El.executeProviderCallable(
    	at org.ocpsoft.rewrite.el.El.access$100(
    	at org.ocpsoft.rewrite.el.El$ElMethod.retrieve(
    	at org.ocpsoft.rewrite.config.Invoke.perform(
    	at org.ocpsoft.rewrite.faces.annotation.config.IgnorePostbackOperation.perform(
    	at org.ocpsoft.rewrite.faces.config.PhaseOperation$1.performOperation(
    	at org.ocpsoft.rewrite.faces.RewritePhaseListener$1.performInSubflow(
    	at org.ocpsoft.rewrite.servlet.event.SubflowTask.perform(
    	at org.ocpsoft.rewrite.faces.RewritePhaseListener.handlePhaseOperation(
    	at org.ocpsoft.rewrite.faces.RewritePhaseListener.handleAfterPhaseOperations(
    	at org.ocpsoft.rewrite.faces.RewritePhaseListener.afterPhase(
    	at com.sun.faces.lifecycle.Phase.handleAfterPhase(
    	at com.sun.faces.lifecycle.Phase.doPhase(
    	at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(
    	at javax.faces.webapp.FacesServlet.service(
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(
    	at org.apache.catalina.core.ApplicationDispatcher.forward(
    	at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    	at org.apache.catalina.core.StandardWrapperValve.invoke(
    	at org.apache.catalina.core.StandardContextValve.invoke(
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
    	at org.apache.catalina.core.StandardHostValve.invoke(
    	at org.apache.catalina.valves.ErrorReportValve.invoke(
    	at org.apache.catalina.valves.AccessLogValve.invoke(
    	at org.apache.catalina.core.StandardEngineValve.invoke(
    	at org.apache.catalina.connector.CoyoteAdapter.service(
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
    	at java.util.concurrent.ThreadPoolExecutor$

    I’m using:
    Apache Tomcat 7.
    JSF 2.2.0(Mojarra)
    Web module 3
    JDK 1.6

    I appreciate your help, thanks


    Hey There,

    Based on the stack trace you pasted, it looks like your method: urlrewrite.action.AboutAction.init( is only called once, from the Rewrite JSF PhaseListener.



    Hi Lincoln,

    Sorry, obviously missed me say that the stack is shown twice. If a Christian is working properly, maybe my development environment is influencing


    Ah, ok. It’s possible that you may have more than one rewrite-servlet or rewrite-integration-faces JAR file on your application classpath. Make sure there are no duplicates. That’s one possible explanation for this.

    Additionally, if you have registered your configuration in multiple places, it will be executed multiple times. E.g: Did you use @RewriteConfiguration and also use the META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider SPI registration mechanism?

    That would also explain this.




    Thanks again Lincoln:

    Sorry for so many problems, answering your question, I have rewrite-servlet-2.0.11.Final.jar and rewrite-integration-faces-2.0.11.Final.jar in the classpath of my project. The only thing I’m using is the class with the annotation @RewriteConfiguration as we can see in the attached.

    I tested the project with Apache 6 and web module 2.5 and it works as expected, but why that behavior? any solution?


    I tested the project with Apache 6 and web module 2.5 and it works as expected, but why that behavior

    So the action is called only once on Tomcat6 but twice on Tomcat7?



    Hello Christian. Yes, exactly


    There seems to be no JSF implementation in the project that you uploaded. As you deploy to a plain Servlet container, it seems like this is missing.

    Also, please check if the two stack traces are EXACTLY the same. A minor difference between them may point us to the root cause of this issue.



    Hello Christian:

    Yes, it’s true, when i uploaded the project I not attached the jar of JSF 2.2 because are 3 MB. (and the Maximum file size allowed is 2048 KB.)

    I did a comparison with a tool(Araxis Merge) of the two stack traces and both are exactly the same. Even I could not find the problem.

    Thanks for your patience

    • This reply was modified 7 years, 9 months ago by  fabricciois.


    Look, this is my complete project:



    any ideas?


    Sorry, I haven’t gotten to take a look at this yet. I wanted to do it tonight but some “real life events” got in the way 🙁 I’ll try to take a look tomorrow.



    I really appreciate it

Viewing 15 posts - 1 through 15 (of 18 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.