13 Replies Latest reply on Oct 6, 2008 3:56 AM by Daniel Nielsen

    Seam Instantiation Exception

    Daniel Nielsen Newbie

      Hi.

      I'm currently evaluating using JSFUnit for our testing purposes. Our application is seam (2.0.2.sp1) based and is deployed as an ear on JBoss (4.2.2) with a war and several ejb modules. I've compiled the latest version of JSFUnit from trunk.

      I've enabled JSFUnit in our war and preliminary testing shows it works. I can run testcases from IDEA, from ant and through the ServletTestRunner. However, when re-running our testcases "fast-enough" I get odd instantiation exceptions from seam. (stacktrace follows). If I just wait a couple of minutes the testcases pass as expected.

      Stack trace:

      Could not instantiate Seam component: componentNavigator
      
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: componentNavigator
      at org.jboss.seam.Component.newInstance(Component.java:1986)
      at org.jboss.seam.Component.getInstance(Component.java:1876)
      at org.jboss.seam.Component.getInstance(Component.java:1843)
      at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
      at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
      at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
      at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
      at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
      at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
      at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
      at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:40)
      at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      at javax.faces.component.UIData.getValue(UIData.java:582)
      at org.ajax4jsf.component.UIDataAdaptor.getValue(UIDataAdaptor.java:1620)
      at org.ajax4jsf.component.SequenceDataAdaptor.getDataModel(SequenceDataAdaptor.java:48)
      at org.ajax4jsf.component.SequenceDataAdaptor.createDataModel(SequenceDataAdaptor.java:42)
      at org.ajax4jsf.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:622)
      at org.ajax4jsf.component.UIDataAdaptor.getRowCount(UIDataAdaptor.java:249)
      at org.jboss.jsfunit.jsfsession.ClientIDs.addUIData(ClientIDs.java:117)
      at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:75)
      at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:83)
      at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:83)
      at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:83)
      at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:83)
      at org.jboss.jsfunit.jsfsession.ClientIDs.<init>(ClientIDs.java:62)
      at org.jboss.jsfunit.jsfsession.JSFServerSession.pageCreated(JSFServerSession.java:181)
      at org.jboss.jsfunit.jsfsession.JSFServerSession.<init>(JSFServerSession.java:54)
      at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:84)
      at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:59)
      at com.blipsystems.blipzones.jsfunit.Login.setUp(Login.java:48)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
      at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
      at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
      at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
      at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
      at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
      at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
      at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
      at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:42)
      at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
      at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
      at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
      at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:48)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122)
      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:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      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:157)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.NullPointerException
      at org.jboss.seam.servlet.ServletRequestSessionMap.put(ServletRequestSessionMap.java:88)
      at org.jboss.seam.servlet.ServletRequestSessionMap.put(ServletRequestSessionMap.java:25)
      at org.jboss.seam.contexts.BasicContext.set(BasicContext.java:80)
      at org.jboss.seam.Component.newInstance(Component.java:1974)
      ... 70 more
      


        • 1. Re: Seam Instantiation Exception
          Stan Silvert Master

           

          "djn" wrote:

          However, when re-running our testcases "fast-enough" I get odd instantiation exceptions from seam. (stacktrace follows). If I just wait a couple of minutes the testcases pass as expected.

          Hi,

          What do you mean by "re-running our testcases fast-enough"?

          What are you waiting for that makes the test cases pass? You are waiting a few seconds/minutes after something else happens?

          Also, can you try Seam 2.1 and see if you get the same result?

          Thanks,

          Stan

          • 2. Re: Seam Instantiation Exception
            Daniel Nielsen Newbie

            Hi.

            Presseing shift-F10 in idea, seeing all tests passed. Changing something, pressing shift-F10 again and some of the test cases fails with the instantiation exception.

            Being puzzled by this, I loaded up the servlettestrunner and loaded the tests. I saw all tests pass, made sure the browser had loaded the page, pressed reload and presto. Some of the tests failed.

            I can reproduce this between stops and starts of the jboss server.

            As for trying seam 2.1, that is a bit into the future for our project. However, I will give it a shot tomorrow.

            Regards,
            Daniel

            • 3. Re: Seam Instantiation Exception
              Stan Silvert Master

              BTW, what is the logging level? Is this WARN, ERROR, FATAL, etc?

              Stan

              • 4. Re: Seam Instantiation Exception
                Daniel Nielsen Newbie

                Hi.

                For JSFUnit and related libraries, the loglevel is DEBUG, although both httpclient and cactus are quite noisy.

                ./Daniel

                • 5. Re: Seam Instantiation Exception
                  Stan Silvert Master

                  Sorry, I wasn't clear. I meant what is the log level of the error you posted?

                  Stan

                  • 6. Re: Seam Instantiation Exception
                    Daniel Nielsen Newbie

                    Ah, well, I wasn't being clear enough either

                    It is my testcases that fail with that error.

                    I have since posting been writing more test cases (for our login page). It is at random these testcases fail. I have seen all of them pass (in the same run) but all too often they fail with a seam error, about reading variables from seam components, instantiate them or otherwise handle them.

                    The only common denominator I've found is that the exceptions' cause is a NullPointerException.

                    I've looked at upgrading seam to v2.1, of course we will upgrade to seam 2.1 eventually, but for now it is too big a task.

                    • 7. Re: Seam Instantiation Exception
                      Daniel Nielsen Newbie

                      Having played around a bit with loglevels and looking a lot closer at the jboss logfiles, I've discoveretsee a lot of exceptions relating to the ServletRedirector (I'm guessing it is used by cactus to run the tests).

                      I dont know if my issues are related to this error.

                      2008-09-29 09:02:33,463 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/blipzones].[ServletRedirector]] Servlet.service() for servlet ServletRedirector threw exception
                      java.lang.IllegalStateException: Unable to invalidate Seam session.
                       at org.jboss.jsfunit.seam.SeamUtil.invalidateSeamSession(SeamUtil.java:100)
                       at org.jboss.jsfunit.framework.JSFUnitServletRedirector.cleanUp(JSFUnitServletRedirector.java:56)
                       at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:49)
                       at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
                       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                       at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122)
                       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:230)
                       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                       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:157)
                       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                       at java.lang.Thread.run(Thread.java:619)
                      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.web.session
                       at org.jboss.seam.Component.newInstance(Component.java:1986)
                       at org.jboss.seam.Component.getInstance(Component.java:1876)
                       at org.jboss.seam.Component.getInstance(Component.java:1855)
                       at org.jboss.seam.Component.getInstance(Component.java:1832)
                       at org.jboss.seam.Component.getInstance(Component.java:1827)
                       at org.jboss.seam.web.Session.instance(Session.java:113)
                       at org.jboss.jsfunit.seam.SeamUtil.invalidateSeamSession(SeamUtil.java:95)
                       ... 25 more
                      Caused by: java.lang.IllegalStateException: Cannot create a session after the response has been committed
                       at org.apache.catalina.connector.Request.doGetSession(Request.java:2301)
                       at org.apache.catalina.connector.Request.getSession(Request.java:2075)
                       at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
                       at org.jboss.seam.servlet.ServletRequestSessionMap.put(ServletRequestSessionMap.java:87)
                       at org.jboss.seam.servlet.ServletRequestSessionMap.put(ServletRequestSessionMap.java:25)
                       at org.jboss.seam.contexts.BasicContext.set(BasicContext.java:80)
                       at org.jboss.seam.Component.newInstance(Component.java:1974)
                       ... 31 more
                      


                      • 8. Re: Seam Instantiation Exception
                        Stan Silvert Master

                        I've tried to recreate this with Seam 2.0.2 SP1, but I can't get it to fail. I run my test from the browser and hit refresh. It works both times.

                        Is there any way you could send me a simple example so I can debug the failure?

                        Stan

                        • 9. Re: Seam Instantiation Exception
                          Daniel Nielsen Newbie

                          I will try.

                          I can create the ServletRedirector exceptions, but the testcase failures are proving a harder to reproduce. I'm looking into it.

                          Regards,
                          ./Daniel

                          • 10. Re: Seam Instantiation Exception
                            Daniel Nielsen Newbie

                            Hi.

                            I've managed to create a simple app that illustrates our issue.

                            It does not happen as often as in our project app, but it happens.

                            In doing so, I've noticed some ugly code in our project - back from when we were learning how to think in seam and it seems to be related to the current issue. However, I'm not sure we do anything illegal in the code.

                            How would you prefer to receive the app? it is too large to send in a mail.

                            Regards,
                            ./Daniel

                            • 11. Re: Seam Instantiation Exception
                              Stan Silvert Master

                              Great. If you have an FTP site then send me an email and tell me how to get it. If not, I'll see what I can provide on my end.

                              stan at jboss dot com

                              • 12. Re: Seam Instantiation Exception
                                Stan Silvert Master

                                I think I found the problem: https://jira.jboss.org/jira/browse/JSFUNIT-171

                                I committed a fix. The tests now pass every time I do a refresh on the browser. You will still see exceptions like this in your log:

                                15:49:13,424 ERROR [SeamPhaseListener] uncaught exception
                                java.lang.IllegalStateException: Could not commit transaction
                                 at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListen
                                er.java:613)
                                 at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(Sea
                                mPhaseListener.java:341)

                                But they don't affect the tests and I'm pretty sure that is fixed in the latest version of Seam.

                                Can you do a build from SVN and check it out on your end?

                                Thanks for your help. The sample app was very useful.

                                Stan

                                • 13. Re: Seam Instantiation Exception
                                  Daniel Nielsen Newbie

                                  I just did a build from svn, and so far i looks good :-)

                                  I've been able to run the testcases about 30 times in a row now with no spurious errors.

                                  Thanks for the quick turnaround.

                                  I will make sure we report any other issues we find, and we will be tracking the trunk version.

                                  Regards,
                                  ./Daniel