11 Replies Latest reply on Sep 5, 2008 2:34 AM by fhomasp

    NoSuchMethodError

    ssilvert

      Moved to a new thread.

      "Fhomasp" wrote:
      Hey,

      Something might be off with automatic library adding on my end. I can't seem to get my initial test off the ground.
      After getting an error exception during the startup of the test I started to add libraries manually by looking them up on the htmlunit page. And so different errors start to come up every time I added another one in my project pom. Right now I'm getting one I can't seem to resolve so easily.

      call
      
      java.lang.NoSuchMethodError: call
      at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(JavaScriptEngine.java:167)
      at com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1084)
      at com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImpl.java:115)
      at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:238)
      at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:116)
      at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:89)
      at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:450)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:359)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:407)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:395)
      at org.jboss.jsfunit.framework.SimpleInitialRequestStrategy.doInitialRequest(SimpleInitialRequestStrategy.java:47)
      at org.jboss.jsfunit.framework.WebClientSpec.doInitialRequest(WebClientSpec.java:232)
      at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:80)
      at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:59)
      at be.vlafo.feniks.web.JSFUnitTest.testInitialPageWithLoginAndDefaultDBInfo(JSFUnitTest.java:65)
      at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
      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(Lorg.apache.cactus.spi.server.ImplicitObjects;)V(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(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(ServletTestRedirector.java:???)
      at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:42)
      at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
      


      This is the simplified test I'm trying to run. I omitted all the other tests. First this one :)
      There might be more problems with this code but the error gets thrown from line 65, which is the declaration of JSFSession object, here on the 4th line.

      public void testInitialPageWithLoginAndDefaultDBInfo() throws IOException,SAXException,TechnicalException {
       JSFClientSession client;
      // JSFSession jsfSession = new JSFSession("/a001/facelets/a001LogIn.jsf");
       JSFSession jsfSession = new JSFSession("/a001/facelets/a001LogIn.jsf");
       client = jsfSession.getJSFClientSession();
       // A JSFServerSession gives you access to JSF state
       JSFServerSession server = jsfSession.getJSFServerSession();
      
       // Test navigation to initial viewID
       assertEquals("/a001/facelets/a001LogIn.xhtml", server.getCurrentViewID());
      
       // Assert that the prompt component is in the component tree and rendered
       UIComponent prompt = server.findComponent("_id18:Rijksregisternummer");
       assertTrue(prompt.isRendered());
       client.setValue("_id18:Rijksregisternummer","53032827321");
       client.setValue("_id18:pincode","123");
       client.click("_id18:_id23");
      
       //testing required fields
       assertEquals("/a001/facelets/a001JSF.xhtml",server.getCurrentViewID());
       assertEquals("TERRIERE", server.getManagedBeanValue("#{A001Bean.naam}"));
       assertEquals("DIRK", server.getManagedBeanValue("#{A001Bean.voorNaam}"));
       assertEquals("Man", server.getManagedBeanValue("#{A001Bean.geslacht}"));
       assertEquals("Gehuwd", server.getManagedBeanValue("#{A001Bean.burgStaat}"));
       }


        • 1. Re: NoSuchMethodError
          ssilvert

          This is probably caused by using the wrong version of a jar. Make sure you are using version 2.2 of htmlunit. Here is the updated list from the gettingstarted page.


          jboss-jsfunit-core-1.0.0.Beta3.jar
          aspectjrt-1.2.1.jar
          cactus-13-1.7.1.jar
          httpunit-1.6.2.jar
          junit-3.8.1.jar
          jtidy-4aug2000r7-dev.jar
          nekohtml-1.9.8.jar
          htmlunit-2.2.jar
          htmlunit-core-js-2.2.jar
          cssparser-0.9.5.jar
          commons-httpclient-3.1.jar
          commons-io-1.4.jar.jar
          sac-1.3.jar
          commons-lang-2.4.jar
          commons-codec-1.3.jar
          commons-logging-1.1.1.jar
          commons-collections-3.2.jar
          js-1.7R1.jar
          cactus-ant-13-1.7.1.jar
          cargo-0.5.jar
          ant-1.5.4.jar

          If not already included in your container, you will also need the jars below. If already installed, you should prefer the container's installed version:

          xercesImpl-2.8.1.jar
          xalan-2.7.0.jar
          xml-apis-1.0.b2.jar


          Auto-add will now tell you the file name of each jar it adds. I found that auto-add leaves out some of the above jars. This will be fixed for GA, but until then you will need to add them manually with the lib tag.

          <!-- Xerces is required for Tomcat, but not Jetty -->
           <!-- We will always bundle it anyway -->
           <property name="xercesImpl.jar" location="${jsfunit.lib.dir}/xercesImpl-2.6.2.jar" />
          
           <!-- Xalan needed by htmlunit, but often included in app server -->
           <property name="xalan.jar" location="${jsfunit.lib.dir}/xalan-2.7.0.jar" />
          
           <delete file="${dest.war}" />
           <jsfunitwar srcfile="${src.war}" destfile="${dest.war}" autoaddjars="true">
           <TestRunner />
           <classes dir="${classes.test}" includes="**/*.class" />
           <lib file="${xercesImpl.jar}" />
           <lib file="${xalan.jar}" />
           </jsfunitwar>


          Stan

          • 2. Re: NoSuchMethodError
            fhomasp

            I keep running into different problems. Now I get two different errors returned in the cactus report.

            When the application is first deployed and I try to run the test, I get the following error:

            com/gargoylesoftware/htmlunit/BrowserVersion
            
            java.lang.NoClassDefFoundError: com/gargoylesoftware/htmlunit/BrowserVersion
            at org.jboss.jsfunit.framework.WebClientSpec.<clinit>(WebClientSpec.java:51)
            at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:59)
            at be.vlafo.feniks.web.JSFUnitTest.testInitialPageWithLoginAndDefaultDBInfo(JSFUnitTest.java:65)
            at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
            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(Lorg.apache.cactus.spi.server.ImplicitObjects;)V(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(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(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(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(ServletTestRedirector.java:???)
            at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:48)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
            at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
            at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
            at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
            at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)


            After this one, when I re-enter the URL I get a NoClassDef Exception:
            I did add all the libs as stated.

            org/jboss/jsfunit/framework/WebClientSpec
            
            java.lang.NoClassDefFoundError: org/jboss/jsfunit/framework/WebClientSpec
            at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:59)
            at be.vlafo.feniks.web.JSFUnitTest.testInitialPageWithLoginAndDefaultDBInfo(JSFUnitTest.java:65)
            at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
            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(Lorg.apache.cactus.spi.server.ImplicitObjects;)V(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(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(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(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(ServletTestRedirector.java:???)
            at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:48)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
            at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
            at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
            at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
            at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
            at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122)
            at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
            


            • 3. Re: NoSuchMethodError
              ssilvert

              My apologies. There are some jars missing from the list. I'll have an updated list shortly. This is the danger of letting maven do all this for me. :-(

              Stan

              • 4. Re: NoSuchMethodError
                fhomasp

                No biggy, I guess we've all had a long week :)

                • 5. Re: NoSuchMethodError
                  ssilvert

                  I updated the list above and also the gettingstarted page.

                  http://www.jboss.org/jsfunit/gettingstarted.html

                  Stan

                  • 6. Re: NoSuchMethodError
                    fhomasp

                    Hey,

                    Using the updated libraries I still get the exact same exceptions while trying to run the testclass.

                    When I debug the code, it gets to the start of the initialisation process of JSFSession, which does not complete and throws the above mentioned exceptions.
                    First the browserVersion exception, always only once at first attempt at running the testclass. Then every other attempt throws the noclassdef.


                    • 7. Re: NoSuchMethodError
                      ssilvert

                      Can you send me the Maven project? I'll be pretty busy with JSFOne this week, but I can try to take a look at it.

                      Stan

                      • 8. Re: NoSuchMethodError
                        fhomasp

                        Hey,

                        I sent you the poms I'm using to config.

                        • 9. Re: NoSuchMethodError
                          fhomasp

                          I found another problem, which I believe is related to this one.

                          I committed and deployed my JSF application to our test server for manual testing. At this point I had only been using it on my own localhost weblogic server.

                          Opening any JSF page gives me this exception:

                          java.lang.NoClassDefFoundError: com/gargoylesoftware/htmlunit/AjaxController
                           at org.jboss.jsfunit.context.JSFUnitFacesContextFactory.isJSFUnitRequest(JSFUnitFacesContextFactory.java:73)
                           at org.jboss.jsfunit.context.JSFUnitFacesContextFactory.getFacesContext(JSFUnitFacesContextFactory.java:57)
                           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:133)
                           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
                           at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
                           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
                           at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                           at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
                           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3368)
                           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                           at weblogic.security.service.SecurityManager.runAs(Unknown Source)
                           at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2117)
                           at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2023)
                           at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)
                           at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
                           at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
                          


                          I'm not even using any JSFUnit code in the regular application, much less any Ajax related component.



                          • 10. Re: NoSuchMethodError
                            ssilvert

                            You still have the JSFUnit jar in your classpath. It automatically installs the JSFUnitFacesContext.

                            Stan

                            • 11. Re: NoSuchMethodError
                              fhomasp

                               

                              "stan.silvert@jboss.com" wrote:
                              You still have the JSFUnit jar in your classpath. It automatically installs the JSFUnitFacesContext.

                              Stan


                              Exactly, together with all other required libraries for running JSFUnit tests. Which is why I'm confident that this error is related to the other problems I've been having. Something is off on classpath with JSFUnit here and I can't seem to lay my finger on it.