13 Replies Latest reply on Feb 26, 2009 7:17 AM by Stan Silvert

    JSFUnit : NoSuchMethodError

    Ernesto Esteban Newbie

      Dear all,

      I'm using JSFUnit for the first time and it half works :)
      Indeed, I'm able to use the TestServlet and my test case but when I try to get the JSFSession I get the following Exception :

      call at

      Here is my code :
      JSFSession jsfSession = new JSFSession("/mypage.jsf");
      JSFServerSession server = jsfSession.getJSFServerSession();

      The ContextFactory class can be found two times, both in the js-1.7R1.jar and in the htmlUnit-cor-js-2.2.jar, that is strange unless the two classes are exactly the same. Anyway I tried to remove one or the other jar the result is the same.
      Hope someone knows how to help me.


        • 1. Re: JSFUnit : NoSuchMethodError
          Stan Silvert Master

          You shouldn't need htmlunit-core-js-2.2.jar. These are the dependencies that are currently required for the htmlunit part:


          The two jars you mentioned in fact do both contain the org.mozilla.javascript.ContextFactory class. But both versions of the class contain the ContextFactory.call method. Perhaps there is another, older, jar in your classpath that has that class also?

          If you investigate and are still stuck, please post the full stack trace.


          • 2. Re: JSFUnit : NoSuchMethodError
            Ernesto Esteban Newbie

            Hello Stan,

            thanks for your answer. I followed your advice and checked that an old jar was not in the classpath. It seems that not as:
            - I removed htmlUnit-core and leave js-1.7R1, the error was the same
            - I removed both jars from the classpath and I got a NoClassDefFound error. Thus I'm sure that there is no other old jar in the classpath.

            I cannot copy/past the stackTrace as our environment is secured but here is a more detailed stackTrace:

            call at
            org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511) at
            com.gargoylesoftware.htmlunit.javascript.JavascriptEngine.initialize(JavascriptEngine.java:134) at
            com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1124) at
            com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImpl.java:93) at
            com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:227) at
            com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:127) at
            org.jboss.jsfunit.framework.JSFSession.<init>(JSFSession.java:80) at

            Hope It's enough to help.
            Thanks again,

            • 3. Re: JSFUnit : NoSuchMethodError
              Stan Silvert Master

              When I look at js-1.7R1.jar, I can see the org.mozilla.javascript.ContextFactory class. When I open that class file with a byte code viewer I can see that it indeed has a "call" method. However, your stack trace claims that the "call" method does not exist.

              Are you running JDK 1.5 or higher? The class was compiled for JDK 1.5, so it won't run properly with JDK 1.4.

              Perhaps you should examine the class yourself with a byte code viewer. The one I use is jclasslib. You can get it at http://www.ej-technologies.com/products/jclasslib/overview.html


              • 4. Re: JSFUnit : NoSuchMethodError
                Ernesto Esteban Newbie

                Hi Stan,

                I followed again your advices and checked the JVM version I'm running. I'm using JRockitR27-2.3 which is BEA improved version mixing classes from several JDK (Indeed I'm using Weblogic as AppServ).
                Then, I changed the runtime and used the JDK150_06 and I went a step further! Indeed, the error is now more detailed, it is in the org.mozilla.javascript.Context class in the method call(ContextFactory, ContextAction).

                I used jclassLib to check that the method is in the js-1.7R1 and it is, with the correct signature! Note that I'm only using the js-1.7R1 jar and not HTMLUnit-core-js jar.

                The stackTract:

                org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511) at
                ...same as before...

                Do I have to use a specific JDK version or do I have to configure something special? It seems you right that the problem comes from my runtime environnement which seems to be not compatible with the JSFUnit libs?

                many thanks again.

                • 5. Re: JSFUnit : NoSuchMethodError
                  Stan Silvert Master

                  I still think the problem is that there is another version of org.mozilla.javascript.Context in your classpath. We need to find out exactly where that class is loaded from.

                  One way to do it is to turn on verbose mode. I'm not sure if JRockit has something like this, but, for example, you can do this with Sun's JDK to see where java.util.ArrayList was loaded from:

                  c:\>java -verbose |grep java.util.ArrayList
                  [Loaded java.util.ArrayList from c:\jdk1.5.0_16\jre\lib\rt.jar]


                  • 6. Re: JSFUnit : NoSuchMethodError
                    Ernesto Esteban Newbie

                    Stan, you're right! But I'm afraid I'll be stuck now...

                    Indeed, thanks to the new stackTrace I had a look to the Context class and not the ContextFactory class. I used a class that gives me the .class location and I found the Context class in the weblogic.jar archive...
                    I used jclasslib to check the existence of the call method and this method does not exist: we've found the problem!

                    However, now that it's in the weblogic.jar I have no options about that, I can't remove it from the weblogic library so I guess I'm quiet stuck. Maybe my environment is not compatible with the last version of JSFUnit? For information I'm running with:
                    - Weblogic 9.2 (JEE 1.4 compliant)
                    - JSF 1.1

                    I cannot upgrade to JSF 1.2 as we are stuck with weblogic 9.2.

                    Do you confirm that my environment is not compatible?

                    you've been very helpful stan, thanks again!

                    • 7. Re: JSFUnit : NoSuchMethodError
                      Stan Silvert Master

                      Since it appears that Weblogic is bundling its own javascript processing library, perhaps you should remove js-1.7R1.jar and see if it works.

                      We have many community developers running JSFUnit on Weblogic, but I have no way of knowing if they are using your version.

                      If the above does not work, then I would contact Weblogic and as which version of the org.mozilla.javascirpt library they are using. If it is an earlier version than 1.7R1 then ask them how it can be upgraded.


                      • 8. Re: JSFUnit : NoSuchMethodError
                        Vasu Srirambhatla Newbie

                        Hi All ,

                        I tried to resolve the same issue by placing js-1.7R1 in the PRE_CLASSPATH in setDomainEnv.cmd

                        But here is the new Error I get

                        tried to access method org.mozilla.javascript.Context.(Lorg/mozilla/javascript/ContextFactory;)V from class com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext

                        java.lang.IllegalAccessError: tried to access method org.mozilla.javascript.Context.(Lorg/mozilla/javascript/ContextFactory;)V from class com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext
                        at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext.(HtmlUnitContextFactory.java:116)
                        at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.makeContext(HtmlUnitContextFactory.java:138)
                        at org.mozilla.javascript.Context.enter(Context.java:401)
                        at org.mozilla.javascript.Context.call(Context.java:497)
                        at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
                        at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(JavaScriptEngine.java:137)
                        at com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1165)
                        at com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImpl.java:93)
                        at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:242)
                        at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:127)
                        at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:101)
                        at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:439)
                        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:327)
                        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:384)
                        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:369)
                        at org.jboss.jsfunit.framework.SimpleInitialRequestStrategy.doInitialRequest(SimpleInitialRequestStrategy.java:47)
                        at org.jboss.jsfunit.framework.WebClientSpec.doInitialRequest(WebClientSpec.java:232)

                        FYI:I am using htmlunit-core-js-2.2.jar.

                        Any help ?

                        • 9. Re: JSFUnit : NoSuchMethodError
                          Stan Silvert Master

                          I'm going to release JSFUnit 1.0 GA in the next day or two. It uses HtmlUnit 2.4 along with its own version of Rhino. Let's wait and see what effect that has.


                          • 10. Re: JSFUnit : NoSuchMethodError
                            Paul van den Berg Newbie

                            I tried the 1.0 GA implementation (from the maven repo) and it causes the same problem as described above. I'm using BEA weblogic 10, so weblogic.jar seems to stay a problem.

                            • 11. Re: JSFUnit : NoSuchMethodError
                              Paul van den Berg Newbie

                              For test purposes I removed org.mozilla.* from weblogic.jar. After restarting the server, the problem is gone, so I can confirm that weblogic.jar is still the problem.

                              • 12. Re: JSFUnit : NoSuchMethodError
                                Paul van den Berg Newbie

                                After some more investigation I found a workable solution for my situation:
                                I added htmlunit-core-js-2.4.jar in the classpath BEFORE weblogic.jar.

                                Another solution could be to add a weblogic.xml to the webproject containing the following line: <prefer-web-inf-classes>true</prefer-web-inf-classes>.

                                The second solution can cause other errors caused by other version incompatabilities.

                                • 13. Re: JSFUnit : NoSuchMethodError
                                  Stan Silvert Master

                                  Thanks for letting us know the solution.