cactus error

T

Tim

I'm looking for help to get me started using Cactus for unit testing. I get
an error instantiating class (see below) when running the tests. I've
provided some info below but don't want this post to be too huge. Please
let me know if any other info would be helpful. I've got another developer
also trying to use Cactus and he's getting the same type of error running
the servlet sample tests that came with Cactus.

Please help!

Here's my setup:
-Java 1.4.2
-J2EE 1.3.1
-JBoss 3.2.1/Tomcat 4.1.24
-Junit 3.8.1
-Ant 1.5.4
-Cactus 13-1.5-rc1

My app is deployed as an ear file. This contains a jar file with ejb files
and a war file. In the war, WEB-INF/classes contains my test class.
My Test method doesn't actually do anything yet but an assertEquals(9,10).
The classpath for the <cactus> ant task points to all the classes in both my
jar and war files, as well as the jars required by cactus (as described in
http://jakarta.apache.org/cactus/integration/howto_classpath.html).

Here's the error from <cactus> ant task:
11:28:46,781 ERROR [AbstractWebTestCaller] Error instantiating class
[com.timtest.TestPerson([testStuff], [null])]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at
org.apache.cactus.server.AbstractWebTestCaller.getTestClassInstance(Abstract
WebTestCaller.java:419)
at
org.apache.cactus.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.
java:148)
at
org.apache.cactus.server.AbstractWebTestController.handleRequest_aroundBody0
(AbstractWebTestController.java:130)
at
org.apache.cactus.server.AbstractWebTestController.handleRequest_aroundBody1
$advice(AbstractWebTestController.java:151)
at
org.apache.cactus.server.AbstractWebTestController.handleRequest(AbstractWeb
TestController.java)
at
org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTes
tRedirector.java:138)
at
org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(Ser
vletTestRedirector.java:151)
at
org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.
java)
at
org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTest
Redirector.java:109)
at
org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(Serv
letTestRedirector.java:151)
at
org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.j
ava)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
46)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:392)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:619)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.VerifyError: (class:
org/apache/cactus/client/connector/http/HttpClientConnectionHelper, method:
addUserData signature: (Lorg/apache/cactus/WebRequest;)V) Incompatible
object argument for function call
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at
org.apache.cactus.configuration.BaseConfiguration.<clinit>(BaseConfiguration
..java:94)
at org.apache.cactus.ServletTestCase.init(ServletTestCase.java:188)
at org.apache.cactus.ServletTestCase.<init>(ServletTestCase.java:164)
at com.timtest.TestPerson.<init>(TestPerson.java:30)
... 50 more

Thanks,
Tim
 
J

John C. Bollinger

Tim said:
I'm looking for help to get me started using Cactus for unit testing. I get
an error instantiating class (see below) when running the tests. I've
provided some info below but don't want this post to be too huge. Please
let me know if any other info would be helpful. I've got another developer
also trying to use Cactus and he's getting the same type of error running
the servlet sample tests that came with Cactus.

Please help!

Here's my setup:
-Java 1.4.2
-J2EE 1.3.1
-JBoss 3.2.1/Tomcat 4.1.24
-Junit 3.8.1
-Ant 1.5.4
-Cactus 13-1.5-rc1

My app is deployed as an ear file. This contains a jar file with ejb files
and a war file. In the war, WEB-INF/classes contains my test class.
My Test method doesn't actually do anything yet but an assertEquals(9,10).
The classpath for the <cactus> ant task points to all the classes in both my
jar and war files, as well as the jars required by cactus (as described in
http://jakarta.apache.org/cactus/integration/howto_classpath.html).

Here's the error from <cactus> ant task:
11:28:46,781 ERROR [AbstractWebTestCaller] Error instantiating class
[com.timtest.TestPerson([testStuff], [null])]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)
at
[...]

Caused by: java.lang.VerifyError: (class:
org/apache/cactus/client/connector/http/HttpClientConnectionHelper, method:
addUserData signature: (Lorg/apache/cactus/WebRequest;)V) Incompatible
object argument for function call
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at
org.apache.cactus.configuration.BaseConfiguration.<clinit>(BaseConfiguration
.java:94)
at org.apache.cactus.ServletTestCase.init(ServletTestCase.java:188)
at org.apache.cactus.ServletTestCase.<init>(ServletTestCase.java:164)
at com.timtest.TestPerson.<init>(TestPerson.java:30)
... 50 more

A VerifyError (!) occurred when Cactus tried to instantiate your test
class. The stack trace indicates exactly which method of which class
was problematic. This almost certainly means that the version of Cactus
against which you compiled differs from the one being used in the
servlet container, or otherwise that the one Cactus build in use is
broken. You probably have more than one version of Cactus lying around.
For instance, your servlet container might ship with one in the
container-wide classpath whereas your app is expecting to use one from
its' war/ear.


John Bollinger
(e-mail address removed)
 
T

Tim

John,

Thanks a lot - you got me looking in the right direction! I've got it
working now. In case anyone else has the same problem...

It turns out that jakarta-cactus-13-1.5-rc1.zip includes
commons-httpclient-2.0-rc2.jar.

It also turns out that jboss-3.2.1_tomcat-4.1.24.zip includes an earlier
version of commons-httpclient.jar in its /lib folder.

I replaced the version in %JBOSS_HOME%/lib with the version that came with
Cactus 1.5 and now my tests work.

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top