7 Replies Latest reply on Mar 18, 2010 10:16 AM by jobb

    JSFUnit 1.2 and JSF 2.0

    jobb

      Hi

      I try to run first time a JSFUnit web application based on my web application based on JSF 2.0.2 and Richfaces 3.3.3.CR1

      When I access a page in my application

       

      11.mar.2010 13:32:19 org.apache.catalina.core.ApplicationDispatcher invoke
      SEVERE: Servlet.service() for servlet Faces Servlet threw exception
      java.lang.StackOverflowError
          at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
          at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)

          ..............

       

      comming up.

       

      Working JSFUnit 1.2.0.Final and  JSF 2.0.2 and Richfaces 3.3.3.CR1 together ?

       

      Regards

      Mirek

        • 1. Re: JSFUnit 1.2 and JSF 2.0
          ssilvert

          Hi,

           

          Sorry for the late reply.  I've been on vacation.

           

          Yes, JSFUnit 1.2 works fine with JSF 2.0.2 and RichFaces 3.3.3.CR1.  I tested with that exact combination (and others) before the release.

           

          If you show more of the stack trace I might be able to tell why you are getting a stack overflow.

           

          Stan

          • 2. Re: JSFUnit 1.2 and JSF 2.0
            jobb

            Hi Stan

            Thank you for your answer. Very shortly explanation what I tried :

            1. Followed documentation , prepared my web application idemWeb-jsfunit

            2. Created a JUnit test using the JSFUnit API, same as you do (http://labs.jboss.com/jsfunit/gettingstarted.html)

            3. Deployed war file to tomcat6

            4. Run this test, using

             

            http://localhost/idemWeb-jsfunit/ServletTestRunner?suite=no.justisnett.idem.web.pass.model.JSFUnitDemoTest&xsl=cactus-report.xsl

             

            Got Cactus Unit Test Results (1 test, 1 Error)

             


            Stdout.log
            15.03.2010 08:36:21 [INFO] JSFUnitDemoTest.suite(21)     TestSuite instansiering...
            15.03.2010 08:36:23 [ERROR] BaseXMLFilter.doXmlFilter(227)     Exception in the filter chain
            javax.servlet.ServletException: Servlet execution threw an exception
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:530)
                    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
                    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
                    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
                    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
                    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:542)
                    at org.jboss.jsfunit.context.JSFUnitDelegatingExternalContext.dispatch(JSFUnitDelegatingExternalContext.java:258)

             

                    at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:355)

             

                    at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:130)
                    at com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:170)
                    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
                    at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
                    at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
                    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
                    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:313)
                    …. Same sequence repeating….

             

            Localhost.log
            INFO: Initializing Spring root WebApplicationContext
            15.mar.2010 08:36:21 org.apache.catalina.core.ApplicationDispatcher invoke
            SEVERE: Servlet.service() for servlet Faces Servlet threw exception
            java.lang.StackOverflowError
                    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
                    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
                    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
                    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
                    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
                    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
                    ….
                    at org.jboss.jsfunit.context.JSFUnitDelegatingExternalContext.getSession(JSFUnitDelegatingExternalContext.java:199)

             

                    at javax.faces.application.ViewHandler.calculateCharacterEncoding(ViewHandler.java:242)
                    at javax.faces.application.ViewHandler.initView(ViewHandler.java:458)
                    at com.sun.faces.application.view.MultiViewHandler.initView(MultiViewHandler.java:106)
                    at org.ajax4jsf.application.ViewHandlerWrapper.initView(ViewHandlerWrapper.java:128)
                    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:109)
                    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:530)
                    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
                    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
                    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
                    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
                    …..repeating

             

            I can send a log files or war file if you wish.

             

            Regards

            Mirek

            • 3. Re: JSFUnit 1.2 and JSF 2.0
              ssilvert

              If you can attach the WAR then that would be very helpful.  I can try it on my end.

               

              Stan

              • 4. Re: JSFUnit 1.2 and JSF 2.0
                jobb

                Hi Stan

                My war file is too big (30Mb). Reason to this is all jar files in lib catalog, something you need to run this application.

                 

                I send you war file without jar files (no choice) , and pom.xml file you can use to generate necessary lib files.

                I had to remove dependency's to my war file, because you can't build this application without more dependencies, parent projects....

                and replaced this with a list of dependencys used in my web application.

                This pom will give you a list of all lib, you should copy all jar files to lib directory in a attached war file.

                 

                 

                Hope you can restore original war file and run this on your server.


                 

                Regards

                Mirek

                • 5. Re: JSFUnit 1.2 and JSF 2.0
                  ssilvert

                  Hi,

                   

                  Does this application work without JSFUnit?  At the point you are getting the stack overflow, JSFUnit is just doing a simple delegation to a wrapped HttpSession.  I don't see how it would cause this problem.

                   

                  There is something unusual in your web.xml:

                      <servlet-mapping>
                          <servlet-name>Faces Servlet</servlet-name>
                          <url-pattern>*.xhtml</url-pattern>
                      </servlet-mapping>
                     <context-param>
                        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                        <param-value>.xhtml</param-value>
                     </context-param>

                   

                  Typically, you map the Faces Servlet to something like *.jsf.

                   

                  Also, I would consider using the new Facelets implementation built into JSF2 instead of 1.1.15.

                   

                  According to this, changing to the JSF2 declaration in faces-config.xml might solve your problem:

                  https://www.ibm.com/developerworks/mydeveloperworks/blogs/hazem/entry/jsf_ri_2_0_1_stackoverflowerror_problem_and_solution2?lang=en

                   

                  I got several Google hits on "StackOverflowError HttpServletRequestWrapper.getSession"  Perhaps one of those solves your problem.

                   

                  Try a few of those things and let me know if you still think it's a JSFUnit problem.

                   

                  Stan


                  • 6. Re: JSFUnit 1.2 and JSF 2.0
                    jobb

                    Hi Stan

                     

                    thank you for your tips.  I found that that wrong faces-config.xml was reason to this error (had version 1.0 and was empty)

                    I just copied a web applications  faces-config.xml to jsfUnit web application, and then I could run application and perform tests.

                     

                    One more question : how to run tests from IDE (Eclipse) ?

                    When I try to execute JUnit fra Eclipse with server running my jspUnit application, a error comming up :

                     

                    org.apache.cactus.util.ChainedRuntimeException: Failed to get the test results at [http://localhost/idemWeb-jsfunit/ServletRedirector]

                        at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:92)
                        at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:306)
                        at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
                        at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
                        at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)
                        at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:306)
                        at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
                        at org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
                        at org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
                        at org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
                        at junit.framework.TestResult$1.protect(TestResult.java:110)
                        at junit.framework.TestResult.runProtected(TestResult.java:128)
                        at junit.framework.TestResult.run(TestResult.java:113)
                        at junit.framework.TestCase.run(TestCase.java:124)
                        at junit.framework.TestSuite.runTest(TestSuite.java:232)
                        at junit.framework.TestSuite.run(TestSuite.java:227)
                        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
                    org.apache.cactus.internal.client.ParsingException: Not a valid response [404 Not Found]

                     

                     

                     

                    Regards

                    Mirek

                    • 7. Re: JSFUnit 1.2 and JSF 2.0
                      jobb

                      Hi

                      I have to answer for myself. After trial and  error I finally got the desired result. Now I can run JSFUnit tests  directly from Eclipse. Hooray
                      But not is all it takes.

                      I am goint to report an exception when I executed Rich Face  Client call (see new post).

                       

                      Regards

                      Mirek