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(XPathAdapter.java:58)
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
http://mail-archives.apache.org/mod_mbox/incubator-yoko-dev/200609.mbox/%3CE91104197DA2654DA833B6EB53B6C488DD6C7A@emea-ems1.dublin.emea.iona.com%3E
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.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>test-compile</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- This needed because jwebunit uses newer version of xalan than regular java -->
<argLine>-Djava.endorsed.dirs=${basedir}/target/endorsed</argLine>
<systemProperties>
<property>
<name>java.endorsed.dirs</name>
<value>${basedir}/target/endorsed</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
Now my tests are running fine.