10 Replies Latest reply on Apr 16, 2012 9:45 AM by javacoryd

    Problem with reverse proxy

    ppc.contactppc.gmail.com

      I've deployed an application.  If it is accessed directly, everything is fine.  But, if it is accessed through reverse proxy, the following exception is thrown.


      2009-11-17 19:30:19,359 SEVERE [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http-0.0.0.0-8080-1)
      JSF1054: (Phase ID: RESTORE_VIEW 1, View ID: ) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1e52afd]
      2009-11-17 19:30:19,390 ERROR [org.jboss.seam.exception.Exceptions] (http-0.0.0.0-8080-1) handled and logged exception
      javax.servlet.ServletException: viewId:/product/priceList.seam - View /product/priceList.seam could not be restored.
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Unknown Source)
      Caused by: javax.faces.application.ViewExpiredException: viewId:/product/priceList.seam - View /product/priceList.seam could not be restored.
           at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
           at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
           ... 43 more
      



      I'm able to log in and submit initial requests.  However, all postbacks fail.  Any idea?

        • 1. Re: Problem with reverse proxy
          meneghette.meneghette.gmail.com

          Hi, I'm having the same problem, any idea ??

          • 2. Re: Problem with reverse proxy
            cbensemann

            Hi, I don't know specifically what the problem is but I will help if I can. I have successfully got several seam apps running behind apache using reverse proxies. I assume that because the app works fine when you access it directly that it has to do with your proxy config. Are you using apache? Can you post your config?


            I am using Apache 2.2 and JBoss 5.1.0. Basically my config in apache looks like this


               <VirtualHost> 
                    ProxyPreserveHost On
                    ProxyPass /site ajp://127.0.0.1:8009/site
                    ProxyPassReverse /site ajp://127.0.0.1:8009/
                </VirtualHost>



            and my context root in application.xml looks like


            <context-root>/site</context-root>



            I would also look at turning your apache (or whatever server you use) logs up to debug as it will often log if it is not forwarding or if the path is incorrect etc.

            • 3. Re: Problem with reverse proxy
              meneghette.meneghette.gmail.com

              This is what's is happening, My application, when I Access works fine, but when my client access doesn't work, the diference is that he access by proxy, when only on person access the application it's works, when two or more access I get ViewExpiredException.


              I thinks the problem is proxy cache, but I already have change my pages adding this meta tag:


              meta http-equiv cache-control content no-cache
              meta http-equiv pragma content no-cache


              But still does not work,


              My application is access by IIS


              Please could you help ?

              • 4. Re: Problem with reverse proxy
                fuzzy333

                Is there only one instance of the application behind the reverse proxy, or do you have some sort of load balanced setup?

                • 5. Re: Problem with reverse proxy
                  meneghette.meneghette.gmail.com

                  Just Only one

                  • 6. Re: Problem with reverse proxy
                    javacoryd

                    We had a similar issue and you proxy may not be looking at the meta cache control tags, but should be looking at HTTP response headers.  We added this phase listener to the application to get by this issue.


                    public class CacheControlPhaseListener implements PhaseListener {
                         
                         private static Date PAST_DATE = null;
                         
                         static {
                              Calendar cal = Calendar.getInstance();
                              cal.set( 1980, 1, 1 );
                              PAST_DATE = cal.getTime();
                         }

                         public void afterPhase( PhaseEvent event ) {
                         }

                         public void beforePhase( PhaseEvent event ) {
                              FacesContext facesContext = event.getFacesContext();
                              HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
                              response.addHeader("Pragma:", "no-cache");
                              response.addHeader("Cache-control:", "private, no-cache, no-store" );
                              response.addDateHeader( "Expires:", PAST_DATE.getTime() );
                         }

                         public PhaseId getPhaseId() {
                              return PhaseId.RENDER_RESPONSE;
                         }

                    }

                    • 7. Re: Problem with reverse proxy
                      meneghette.meneghette.gmail.com

                      I will try this, and I let you know if this works

                      • 8. Re: Problem with reverse proxy
                        meneghette.meneghette.gmail.com

                        Hi Cory,


                        We are using the application for 2 days, and it seams the problem was solved.


                        Thanks for your help,


                        I have to pay for you a beer box....

                        • 9. Re: Problem with reverse proxy
                          x099008

                          Cory,

                           

                          Can you give some detail on the config you used when setting up this phase listener ?

                           

                          -Thanks

                          • 10. Re: Problem with reverse proxy
                            javacoryd

                            Add this to faces-config.xml:

                            <lifecycle>

                                  <phase-listener>yourpackage.CacheControlPhaseListener</phase-listener>

                            </lifecycle>

                             

                            Cory.