ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vikas Malla <malla...@yahoo.co.in>
Subject Re: java.lang.NoClassDefFoundError
Date Fri, 18 Oct 2002 14:06:33 GMT

Please find my build.xml.

Please let me know.

Thanks.

<!--build.xml starts HERE-->

<project name="testCactus" default="testNow" basedir=".">


<!--
   ======================================================================
     Set the properties that specify paths
   ======================================================================
-->

<property name="tomcat.home" value="C:/jakarta-tomcat-4.0.3"/>
<property name="tomcat.lib"  value="${tomcat.home}/common/lib"/>
<property name="my.home"  value="C:/my/test"/>
<property name="my.lib"  value="${my.home}/WEB-INF/lib"/>
<property name="my.classes" value="${my.home}/WEB-INF/classes"/>
<property name="cactus.ant.jar" value="${tomcat.lib}/cactus-ant-1.4.jar"/>


<!--
   ======================================================================
     Initialize the build. Must be called by all targets
   ======================================================================
-->
<target name="init">
    <!-- Create the time stamp -->
    <tstamp/>
    <taskdef name="runservertests" classname="org.apache.cactus.ant.RunServerTestsTask">
        <classpath>
            <pathelement location="${cactus.ant.jar}"/>
        </classpath>
    </taskdef>
</target>


<!--
   ========================================================================
     Start Tomcat 4.0
   ========================================================================
-->
<target name="start.tomcat">

    <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
        <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
        <arg value="start"/>
        <classpath>
          <fileset dir="${tomcat.home}">
              <include name="bin/bootstrap.jar"/>
          </fileset>
        </classpath>
    </java>

</target>


<!--
   ========================================================================
     Stop Tomcat 4.0
   ========================================================================
-->
<target name="stop.tomcat">
              <!--fork="yes"-->
    <java classname="org.apache.catalina.startup.Bootstrap" fork="yes" >
        <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
        <arg value="stop"/>
        <classpath>
          <fileset dir="${tomcat.home}">
              <include name="bin/bootstrap.jar"/>
          </fileset>
        </classpath>
    </java>

</target>


<!-- ==================== Compilation Classpath =========================== -->

  <path id="my.classpath">

    <!-- this is where I have my MyTest.java -->
    <pathelement location="${tomcat.home}/common/classes"/>

    <fileset dir="${tomcat.home}/common/lib">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="${tomcat.home}/lib">
      <include name="*.jar"/>
    </fileset>

  </path>


<!--
   ========================================================================
     Run the client JUnit test cases.
   ========================================================================
-->
<target name="test">

    <junit printsummary="yes" haltonfailure="yes" haltonerror="yes"
        fork="yes">

        <classpath>
            <!-- Cactus.properties and log_client.properties need to be in
                 the classpath -->

            <pathelement location="${my.classes}/cactus.properties"/>
   <pathelement location="${my.classes}/log_client.properties"/>
   <!--This is where I have my package defined-->
   <pathelement location="${my.classes}"/>
            <path refid="my.classpath"/>
        </classpath>

        <formatter type="plain" usefile="false"/><test name="MyTest"/>    
 </junit>

</target>


<!--
   ========================================================================
     Run Tomcat 4.0 tests
   ========================================================================
-->
<target name="testNow" depends="init" if="tomcat.home" description="Run tests on Tomcat">

    <!-- Start the servlet engine, wait for it to be started, run the
         unit tests, stop the servlet engine, wait for it to be stopped.
         The servlet engine is stopped if the tests fail for any reason -->
    <runservertests
        testURL="http://localhost:8080/ServletTestRunner?suite=TestSampleServlet"
        startTarget="start.tomcat"
        stopTarget="stop.tomcat"
        testTarget="test"/>
</target>

</project>

<!--ENDS HERE-->

 

Thanks.

Vikas

 Erik Hatcher <jakarta-ant@ehatchersolutions.com> wrote: Vikas Malla wrote:
> Help is required to solve this problem:
> 
> I am trying to run this test MyTest.java . I make some API calls ,defined in a package
myPackage.f1.f2.f3.MyBean, in MyTest.java
> 
> I am able to compile this file. But when I run this test using ant, I get NoClassDefFoundError.
Please keep in mind that I am able to compile this file, so the possibility of not having
this in my classpath is ruled out(i think so).


Nope, its not ruled out. In fact, this is surely the reason its 
failing. When you compile, you don't have the code you're compiling in 
your classpath, but you need the code you just compiled in your 
classpath. Provide us with both your and details and 
lets have a closer look.

Erik


--
To unsubscribe, e-mail: 
For additional commands, e-mail: 

 Yahoo! Properties Special  Buy, sell, rent...your flat, or even post an ad
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message