You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by "Dickinson, Ian J. (HP Labs, Bristol, UK)" <ia...@hp.com> on 2006/04/27 15:34:16 UTC

Problem running cactus from ant

Hi,
I'm just getting going with using Cactus to test a J2EE project. I've
built my cactified .war and deployed the .ear. I can run a simple test
successfully using the ServletRunner on the server, but if I try to
invoke the same test from the cactus task in ant, I get a
ClassNotFoundException:

Buildfile: c:\home\ijd\projects2\vrmm-apps-phm\build.xml
run-cactus:
   [cactus]
-----------------------------------------------------------------
   [cactus] Running tests against JBossGeneric @ http://localhost:8088
   [cactus]
-----------------------------------------------------------------
   [cactus] Running com.hp.vrmm.station.StationInfoFacadeBeanTest
   [cactus] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
   [cactus] Testsuite: com.hp.vrmm.station.StationInfoFacadeBeanTest
   [cactus] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
   [cactus] Caused an ERROR
   [cactus] com.hp.vrmm.station.StationInfoFacadeBeanTest
   [cactus] java.lang.ClassNotFoundException:
com.hp.vrmm.station.StationInfoFacadeBeanTest
   [cactus] at java.net.URLClassLoader$1.run(Unknown Source)
   [cactus] at java.security.AccessController.doPrivileged(Native
Method)
   [cactus] at java.net.URLClassLoader.findClass(Unknown Source)
   [cactus] at java.lang.ClassLoader.loadClass(Unknown Source)
   [cactus] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
Source)
   [cactus] at java.lang.ClassLoader.loadClass(Unknown Source)
   [cactus] at java.lang.ClassLoader.loadClassInternal(Unknown Source)
   [cactus] at java.lang.Class.forName0(Native Method)
   [cactus] at java.lang.Class.forName(Unknown Source)

BUILD FAILED
C:\home\ijd\projects2\vrmm-apps-phm\build.xml:61: Test
com.hp.vrmm.station.StationInfoFacadeBeanTest failed

Total time: 2 seconds


The named class is present under WEB-INF/classes in the cactified .war,
and, indeed, is invoked from the servlet test runner. My cactus task
looks like this:

  <target name="run-cactus">
      <cactus earfile="${build.dir}/test-${ear.name}" fork="yes"
              printsummary="yes" haltonerror="true"
haltonfailure="false">
        <containerset>
          <generic name="JBossGeneric" port="8088">
            <startup target="generic.jboss.deploy"/>
            <shutdown target="generic.jboss.undeploy"/>
          </generic>
        </containerset>
        <formatter type="plain" usefile="false"/>
        <test name="com.hp.vrmm.station.StationInfoFacadeBeanTest" />
      </cactus>
  </target>

Following the advice of another posting on this list, I'm using a
generic server description to deploy to JBoss 4.0.3SP1.  The rest of my
environment is: Ant 1.6.5, jakarta-cactus-13-1.7.2 and JDK 1.5.0-06.

Any suggestions would be much appreciated!

Thanks,
Ian

________________________________________________________________________
_
Ian Dickinson    HP Labs, Bristol, UK    Semantic & Adaptive Systems
Dept
http://www.hpl.hp.com/people/Ian_Dickinson
mailto:ian.dickinson@hp.com

Re: Problem running cactus from ant

Posted by Kazuhito SUGURI <su...@lab.ntt.co.jp>.
Hi Ian,

In article <DE...@sdcexc04.emea.cpqcorp.net>,
Thu, 27 Apr 2006 14:34:16 +0100,
"Dickinson, Ian J. (HP Labs, Bristol, UK)" <ia...@hp.com> wrote: 
ian> I'm just getting going with using Cactus to test a J2EE project. I've
ian> built my cactified .war and deployed the .ear. I can run a simple test
ian> successfully using the ServletRunner on the server, but if I try to
ian> invoke the same test from the cactus task in ant, I get a
ian> ClassNotFoundException:
[snip]
ian>    [cactus] Caused an ERROR
ian>    [cactus] com.hp.vrmm.station.StationInfoFacadeBeanTest
ian>    [cactus] java.lang.ClassNotFoundException:
ian> com.hp.vrmm.station.StationInfoFacadeBeanTest
[snip]
ian> The named class is present under WEB-INF/classes in the cactified .war,
ian> and, indeed, is invoked from the servlet test runner. My cactus task
ian> looks like this:

You have to set a client-side classpath properly.


ian>   <target name="run-cactus">
ian>       <cactus earfile="${build.dir}/test-${ear.name}" fork="yes"
ian>               printsummary="yes" haltonerror="true"
ian> haltonfailure="false">
ian>         <containerset>
ian>           <generic name="JBossGeneric" port="8088">
ian>             <startup target="generic.jboss.deploy"/>
ian>             <shutdown target="generic.jboss.undeploy"/>
ian>           </generic>
ian>         </containerset>
ian>         <formatter type="plain" usefile="false"/>
ian>         <test name="com.hp.vrmm.station.StationInfoFacadeBeanTest" />
ian>       </cactus>
ian>   </target>

As cactus ant-task is an extension of junit ant-task,
you can set the client-side classpath by using
classpath nested-element for the cactus task.

You may have already solved the problem, though.

Hope this helps,
----
Kazuhito SUGURI