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

Tagged: 

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

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

    fabricciois
    Participant

    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

    Attachments:
    1. rewrite.rar
    #26019

    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.

    #26020

    fabricciois
    Participant

    Hello:

    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(Thread.java:1249)
    	at urlrewrite.action.AboutAction.init(AboutAction.java:15)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
    	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
    	at org.ocpsoft.rewrite.faces.FacesExpressionLanguageProvider.evaluateMethodExpression(FacesExpressionLanguageProvider.java:116)
    	at org.ocpsoft.rewrite.faces.FacesExpressionLanguageProvider.evaluateMethodExpression(FacesExpressionLanguageProvider.java:104)
    	at org.ocpsoft.rewrite.el.El$ElMethod$1.call(El.java:215)
    	at org.ocpsoft.rewrite.el.El.executeProviderCallable(El.java:171)
    	at org.ocpsoft.rewrite.el.El.access$100(El.java:40)
    	at org.ocpsoft.rewrite.el.El$ElMethod.retrieve(El.java:210)
    	at org.ocpsoft.rewrite.config.Invoke.perform(Invoke.java:52)
    	at org.ocpsoft.rewrite.faces.annotation.config.IgnorePostbackOperation.perform(IgnorePostbackOperation.java:56)
    	at org.ocpsoft.rewrite.faces.config.PhaseOperation$1.performOperation(PhaseOperation.java:80)
    	at org.ocpsoft.rewrite.faces.RewritePhaseListener$1.performInSubflow(RewritePhaseListener.java:134)
    	at org.ocpsoft.rewrite.servlet.event.SubflowTask.perform(SubflowTask.java:61)
    	at org.ocpsoft.rewrite.faces.RewritePhaseListener.handlePhaseOperation(RewritePhaseListener.java:127)
    	at org.ocpsoft.rewrite.faces.RewritePhaseListener.handleAfterPhaseOperations(RewritePhaseListener.java:110)
    	at org.ocpsoft.rewrite.faces.RewritePhaseListener.afterPhase(RewritePhaseListener.java:64)
    	at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)
    	at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121)
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    	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:205)
    	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:749)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    	at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:38)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:268)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:188)
    	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:222)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
    	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)

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

    I appreciate your help, thanks

    #26021

    Hey There,

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

    #26022

    fabricciois
    Participant

    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

    #26023

    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.

    ~Lincoln

    #26024

    fabricciois
    Participant

    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?
    Thanks

    #26025

    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?

    #26026

    fabricciois
    Participant

    Hello Christian. Yes, exactly

    #26027

    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.

    #26028

    fabricciois
    Participant

    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 2 years, 4 months ago by  fabricciois.
    #26030

    fabricciois
    Participant

    Look, this is my complete project:

    http://www.sendspace.com/file/43ycd2

    #26052

    fabricciois
    Participant

    any ideas?

    #26054

    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.

    #26059

    fabricciois
    Participant

    I really appreciate it

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

You must be logged in to reply to this topic.

Comments are closed.