Menu

Ant "Java" class for "emmajavaTask" not found

2004-10-02
2013-05-09
  • David Bernstein

    David Bernstein - 2004-10-02

    I'm having a problem using Ant 1.6.2, JDK 1.4.2_05, and Emma 2.0.4217 on WinXP.

    I tried to follow the user guide instructions, but if I've made a newbie
    error, apologies in advance.  I put the two emma jar files in my Java
    extensions directory, and copied the Ant code directly from the
    "3.1. Adding EMMA tasks to your ANT build" section, just changing the
    emma.dir property value to my extensions directory (problem occurs even
    if I use another directory).  When I try to do a build, I get:

    "A class needed by class com.vladium.emma.emmajavaTask cannot be found: org/apache/tools/ant/taskdefs/Java"

    I believe I've got everything relevant to duplicating my problem listed
    below.  I saw something in the discussions about Ant 1.6 not being
    supported for building, but this isn't about building emma and the reference
    manual says it works with Ant 1.4.1 and later and 1.6 has been production
    since December 2003 and I really need 1.6.2. :-)

    Thanks in advance!

    ======================================================================

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    c:\eclipse\workspace\kit>ant -version
    ant -version
    Apache Ant version 1.6.2 compiled on July 16 2004
    c:\eclipse\workspace\kit>java -version
    java -version
    java version "1.4.2_05"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
    Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

    c:\eclipse\workspace\kit>type build_emma_bug.xml
    type build_emma_bug.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="EmmaBug" basedir="." default="init">

        <target name="init">
            <tstamp/>
        </target>

        <!-- this depends on having place the emma jar files in JRE lib/ext dir -->
        <property name="emma.dir" value="${java.ext.dirs}" />

        <path id="emma.lib" >
            <pathelement location="${emma.dir}/emma.jar" />
            <pathelement location="${emma.dir}/emma_ant.jar" />
        </path>

        <taskdef resource="emma_ant.properties" classpathref="emma.lib" />

        <target name="emma" description="turns on EMMA instrumentation/reporting" depends="init" >
            <!-- is empty -->
        </target>
    </project>

    c:\eclipse\workspace\kit>ant -f build_emma_bug.xml emma
    ant -f build_emma_bug.xml emma
    Buildfile: build_emma_bug.xml

    BUILD FAILED
    C:\eclipse\workspace\kit\build_emma_bug.xml:16: taskdef A class needed by class com.vladium.emma.emmajavaTask cannot be found: org/apache/tools/ant/taskdefs/Java

    Total time: 0 seconds
    c:\eclipse\workspace\kit>ant -f build_emma_bug.xml -verbose -diagnostics emma
    ant -f build_emma_bug.xml -verbose -diagnostics emma
    Apache Ant version 1.6.2 compiled on July 16 2004
    ------- Ant diagnostics report -------
    Apache Ant version 1.6.2 compiled on July 16 2004

    -------------------------------------------
    Implementation Version (JDK1.2+ only)
    -------------------------------------------
    core tasks     : 1.6.2
    optional tasks : 1.6.2

    -------------------------------------------
    ANT_HOME/lib jar listing
    -------------------------------------------
    ant.home: C:\java\ant\apache-ant-1.6.2
    ant-antlr.jar (5659 bytes)
    ant-apache-bcel.jar (8609 bytes)
    ant-apache-bsf.jar (12589 bytes)
    ant-apache-log4j.jar (3014 bytes)
    ant-apache-oro.jar (48015 bytes)
    ant-apache-regexp.jar (3706 bytes)
    ant-apache-resolver.jar (4073 bytes)
    ant-commons-logging.jar (3856 bytes)
    ant-commons-net.jar (35242 bytes)
    ant-icontract.jar (9713 bytes)
    ant-jai.jar (21351 bytes)
    ant-javamail.jar (6753 bytes)
    ant-jdepend.jar (8152 bytes)
    ant-jmf.jar (6596 bytes)
    ant-jsch.jar (22604 bytes)
    ant-junit.jar (73665 bytes)
    ant-launcher.jar (8673 bytes)
    ant-netrexx.jar (9990 bytes)
    ant-nodeps.jar (407573 bytes)
    ant-starteam.jar (35463 bytes)
    ant-stylebook.jar (2320 bytes)
    ant-swing.jar (6755 bytes)
    ant-trax.jar (68833 bytes)
    ant-vaj.jar (48623 bytes)
    ant-weblogic.jar (14355 bytes)
    ant-xalan1.jar (4457 bytes)
    ant-xslp.jar (2236 bytes)
    ant.jar (999966 bytes)
    junit.jar (121070 bytes)
    xercesImpl.jar (1010675 bytes)
    xml-apis.jar (124724 bytes)

    -------------------------------------------
    Tasks availability
    -------------------------------------------
    image : Missing dependency com.sun.media.jai.codec.FileSeekableStream
    sshexec : Missing dependency com.jcraft.jsch.UserInfo
    scp : Missing dependency com.jcraft.jsch.UserInfo
    cvsversion : Not Available
    jdepend : Missing dependency jdepend.xmlui.JDepend

    -------------------------------------------
    org.apache.env.Which diagnostics
    -------------------------------------------
    Not available.
    Download it at http://xml.apache.org/commons/

    -------------------------------------------
    XML Parser information
    -------------------------------------------
    XML Parser : org.apache.xerces.jaxp.SAXParserImpl
    XML Parser Location: C:\java\ant\apache-ant-1.6.2\lib\xercesImpl.jar

    -------------------------------------------
    System properties
    -------------------------------------------
    java.runtime.name : Java(TM) 2 Runtime Environment, Standard Edition
    sun.boot.library.path : C:\java\j2se\1.4.2_05\jre\bin
    java.vm.version : 1.4.2_05-b04
    ant.library.dir : C:\java\ant\apache-ant-1.6.2\lib
    java.vm.vendor : Sun Microsystems Inc.
    java.vendor.url : http://java.sun.com/
    path.separator : ;
    java.vm.name : Java HotSpot(TM) Client VM
    file.encoding.pkg : sun.io
    user.country : US
    sun.os.patch.level : Service Pack 1
    java.vm.specification.name : Java Virtual Machine Specification
    user.dir : c:\eclipse\workspace\kit
    java.runtime.version : 1.4.2_05-b04
    java.awt.graphicsenv : sun.awt.Win32GraphicsEnvironment
    java.endorsed.dirs : C:\java\j2se\1.4.2_05\jre\lib\endorsed
    os.arch : x86
    java.io.tmpdir : C:\DOCUME~1\David\LOCALS~1\Temp\ line.separator :

    java.vm.specification.vendor : Sun Microsystems Inc.
    user.variant :
    os.name : Windows XP
    ant.home : C:\java\ant\apache-ant-1.6.2
    sun.java2d.fontpath :
    java.library.path : C:\java\j2se\1.4.2_05\bin;.;C:\WINDOWS\System32;C:\WINDOWS;c:\bin;C:\java\j2se\1.4.2_05\bin;C:\java\ant\apache-ant-1.6.2\bin;C:\cygwin\bin;C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\PROGRA~1\COMMON~1\SONICS~1\;C:\java\jwsdp\1.4\jwsdp-shared\bin
    java.specification.name : Java Platform API Specification
    java.class.version : 48.0
    java.util.prefs.PreferencesFactory : java.util.prefs.WindowsPreferencesFactory
    os.version : 5.1
    user.home : C:\Documents and Settings\David
    user.timezone : America/Los_Angeles
    java.awt.printerjob : sun.awt.windows.WPrinterJob
    file.encoding : Cp1252
    java.specification.version : 1.4
    java.class.path : C:\java\ant\apache-ant-1.6.2\lib\ant-launcher.jar;C:\Program Files\Altova\xmlspy\XMLSpyInterface.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-antlr.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-apache-bcel.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-apache-bsf.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-apache-log4j.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-apache-oro.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-apache-regexp.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-apache-resolver.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-commons-logging.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-commons-net.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-icontract.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-jai.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-javamail.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-jdepend.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-jmf.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-jsch.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-junit.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-launcher.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-netrexx.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-nodeps.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-starteam.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-stylebook.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-swing.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-trax.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-vaj.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-weblogic.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-xalan1.jar;C:\java\ant\apache-ant-1.6.2\lib\ant-xslp.jar;C:\java\ant\apache-ant-1.6.2\lib\ant.jar;C:\java\ant\apache-ant-1.6.2\lib\junit.jar;C:\java\ant\apache-ant-1.6.2\lib\xercesImpl.jar;C:\java\ant\apache-ant-1.6.2\lib\xml-apis.jar;C:\java\j2se\1.4.2_05\lib\tools.jar
    user.name : David
    java.vm.specification.version : 1.0
    java.home : C:\java\j2se\1.4.2_05\jre
    sun.arch.data.model : 32
    user.language : en
    java.specification.vendor : Sun Microsystems Inc.
    awt.toolkit : sun.awt.windows.WToolkit
    java.vm.info : mixed mode
    java.version : 1.4.2_05
    java.ext.dirs : C:\java\j2se\1.4.2_05\jre\lib\ext
    sun.boot.class.path : C:\java\j2se\1.4.2_05\jre\lib\rt.jar;C:\java\j2se\1.4.2_05\jre\lib\i18n.jar;C:\java\j2se\1.4.2_05\jre\lib\sunrsasign.jar;C:\java\j2se\1.4.2_05\jre\lib\jsse.jar;C:\java\j2se\1.4.2_05\jre\lib\jce.jar;C:\java\j2se\1.4.2_05\jre\lib\charsets.jar;C:\java\j2se\1.4.2_05\jre\classes
    java.vendor : Sun Microsystems Inc.
    file.separator : \ java.vendor.url.bug : http://java.sun.com/cgi-bin/bugreport.cgi
    sun.io.unicode.encoding : UnicodeLittle
    sun.cpu.endian : little
    sun.cpu.isalist : pentium i486 i386

    c:\eclipse\workspace\kit>dir C:\java\j2se\1.4.2_05\jre\lib\ext
    dir C:\java\j2se\1.4.2_05\jre\lib\ext
    Volume in drive C has no label.
    Volume Serial Number is 38EC-6039

    Directory of C:\java\j2se\1.4.2_05\jre\lib\ext

    09/30/2004  02:46 PM    <DIR>          .
    09/30/2004  02:46 PM    <DIR>          ..
    06/03/2004  09:37 PM             8,896 dnsns.jar
    07/17/2004  12:20 PM           433,148 emma.jar
    07/17/2004  12:20 PM            38,761 emma_ant.jar
    06/03/2004  09:40 PM            53,248 ldapsec.jar
    06/03/2004  10:11 PM           769,342 localedata.jar
    06/03/2004  09:05 PM           111,430 sunjce_provider.jar
                   6 File(s)      1,414,825 bytes
                   2 Dir(s)  474,785,538,048 bytes free

    c:\eclipse\workspace\kit>

     
    • Vlad Roubtsov

      Vlad Roubtsov - 2004-10-02

      David,
      Thanks for providing such detailed info (I wish everyone did the same).

      The fact that your ANT version is 1.6.2 is irrelevant, I think. EMMA builds and works in ANT 1.6.1 just fine (using it with JUnit at work right now) and I don't think 1.6.2 has changed things drastically.

      What I am going to suggest may sound confusing, but I think I know what your problem might be:

      You are mixing two different ways to deploy something as a library: install it as a JRE extension or place it in some classpath (which is what basically happens in ANT). Although it seems similar, which classloader loads what is important.

      Sigh. I really need to work on my docs some more to make this clear in all contexts (command line and ANT). So, here goes:

      Only emma.jar (which contains EMMA runtime) should be installed as a JRE extension. If emma_ant is also in the extension directory, it will be loaded by the extension classloader and subsequently things will fail because the rest of ANT stuff is not there.

      Unfortunately, ANT poor classloading complicates things. To keep things simple, try this:

      (1) leave *only* emma.jar in the JRE extension directory. Yes, you actually need to remove emma_ant.jar from there. Failing to do that is why your attempt to use a different directory did not work.

      (2) copy both jars into a *different* directory that will become your "emma.lib" in ANT

      Things should work now. If not, try my ANT samples, they should work out of the box. If they don't work, I will need to examine ANT 1.6.2 more closely.

       
    • David Bernstein

      David Bernstein - 2004-10-02

      Vlad,

      Thanks for the quick response!  (I've gotten my share of poor bug reports so I empathize with you!)  Removing emma_ant.jar got the slimmed down test case to work.  I now understand why, although I don't know if I'd have figured it out without your help.  Since it's already Friday evening and the complete setup I'm trying to make work is a bit more complicated I think I'll defer that to tomorrow.  I'm really looking forward to finding out how much of our code our test suite covers.

      Thanks again!
      Dave

       
    • David Bernstein

      David Bernstein - 2004-10-04

      I've got my first coverage report now!  Thanks!

       

Log in to post a comment.