Thursday, October 30, 2008

WebTest Groovy example thows NoSuchMethodError

I've been working on a project to do functional testing on a web application using WebTest. I've coded up some prototypes using the standard XML/Ant format/language/DSL, but I wanted to try doing it in Groovy, since I'm not a big fan of XML. I copied the sample application from the manual, but when I ran it I was getting and exception:

Caught: : java.lang.NoSuchMethodError: org.apache.xpath.compiler.FunctionTable.installFunction(Ljava/lang/String;Ljava/lang/Class;)I
at test.main(test.groovy)

(If you're following along at home, you'll note that that line number is too large for the example - I've already hacked some stuff into it.)

I couldn't find any examples online of people having exactly the same problem, but I'd seen other errors blaming an old version of xalan.jar for this problem, especially under Mac OS 10.5 - my platform. (BTW, this happened under both Java5 and Java6.) Although I didn't have CLASSPATH set to anything, I figured I'd try setting it to have the version of xalan.jar that ships with WebTest, and it worked. So, my complete invocation line is:

groovy -cp /usr/local/java/webtest_1720/lib/xalan-2.7.0.jar -Dwebtest.home=/usr/local/java/webtest_1720 test.groovy



Immo Hüneke said...

Thanks - you have confirmed my suspicions there. I am having a similar problem under Mac OSX 10.4 running WebTest as part of an Ant build. The annoying thing is that I cannot find out how WebTest is invoking groovy - so I don't have any idea where it is getting the out-of-date org.apache.xpath from!

Immo Hüneke said...

Found the problem in the end - Ant needs xalan-2.7.0.jar on its classpath (I can invoke it like that from the shell). Now I just have to find out where to configure that in Eclipse. Ah, here we are: Top Menu -> Window (or Eclipse in the case of Mac OSX) -> Preferences -> Ant -> Runtime. That should do it!

Charles Anderson said...

Good luck tracking that down. I assumed the bogus jar was something in Apple's Java distro. Once I found a work-around, I just moved on because I was in a proof-of-concept phase and needed to keep moving ahead.

Unknown said...

Thanks a saved my life....