Wednesday, November 26, 2008

Overriding java endorsed direcctory for maven unit tests.

I was testing a web application using jwebunit (which has great ajax support
because of htmlunit). The test was running fine in Eclipse, but when I wanted
to run it from maven as a unit test I got an exception that started like this

java.lang.NoSuchMethodError: org.apache.xpath.compiler.FunctionTable.installFunction(Ljava/lang/String;Ljava/lang/Class;)I
at com.gargoylesoftware.htmlunit.html.xpath.XPathAdapter.initFunctionTable(

Another blog posting helped me identify that root cause was the xalan that is
included with my Mac osx version 1.5 of java is older than what the htmlunit
package was using. I found an email

that told me how to add a argLine to the maven-surefire-plugin.

And below is how I fix this in the "build" section my pom.xml.

<!-- This needed because jwebunit uses newer version of xalan than regular java -->

Now my tests are running fine.

No comments: