If you are using this classpath:

 

        <path id="cobertura.classpath">
                <fileset dir="${cobertura.dir}">
                        <include name="cobertura.jar" />
                        <include name="lib/**/*.jar" />
                </fileset>
        </path>

 

The log4j.jar needs to be under the lib dir.

 

Can you show us your ant script?

 

John

 

From: Chris Stoughton [mailto:chris.stoughton@gmail.com]
Sent: Thursday, March 19, 2009 9:56 AM
To: John W. Lewis
Cc: cobertura-devel@lists.sourceforge.net
Subject: Re: [Cobertura-devel] examples/basic problem

 

Thanks, but that still gives the same problem.  Perhaps I am not understanding your suggestion.  In the original distribution, the log4j jar file is in the lib directory.  I thought your first suggestion was to put log4j up one directory.  I put it back in lib.  Here is what the directories look like now:

-bash-3.00$ pwd
~/cobertura-1.9.1/examples/basic
-bash-3.00$ ls ../../
ChangeLog            cobertura-instrument.bat  cobertura-merge.sh    COPYRIGHT
cobertura-check.bat  cobertura-instrument.sh   cobertura-report.bat  examples
cobertura-check.sh   cobertura.jar             cobertura-report.sh   lib
coberturaFlush.war   cobertura-merge.bat       COPYING               README
-bash-3.00$ ls ../../lib
asm-3.0.jar       jakarta-oro-2.0.8.jar    log4j-1.2.9.jar
asm-tree-3.0.jar  jakarta-oro-license.txt  log4j-license.txt

On Thu, Mar 19, 2009 at 8:15 AM, John W. Lewis <JohnW.Lewis@sas.com> wrote:

 

Move the log4j.jar into the lib dir.

 

From: Chris Stoughton [mailto:chris.stoughton@gmail.com]
Sent: Thursday, March 19, 2009 8:52 AM
To: John W. Lewis
Cc: cobertura-devel@lists.sourceforge.net
Subject: Re: [Cobertura-devel] examples/basic problem

 

From the coberture-1.9.1/examples/basic directory, I did this:

$ mv ../../lib/log4j-1.2.9.jar ../..
so the directories look like this:
$ ls ../..
ChangeLog                 cobertura.jar         COPYRIGHT
cobertura-check.bat       cobertura-merge.bat   examples
cobertura-check.sh        cobertura-merge.sh    lib
coberturaFlush.war        cobertura-report.bat  log4j-1.2.9.jar
cobertura-instrument.bat  cobertura-report.sh   README
cobertura-instrument.sh   COPYING

and this:

$ ls ../../lib
asm-3.0.jar       jakarta-oro-2.0.8.jar    log4j-license.txt
asm-tree-3.0.jar  jakarta-oro-license.txt

Recall that the build.xml file declares this at the top:
        <path id="cobertura.classpath">
                <fileset dir="${cobertura.dir}">
                        <include name="cobertura.jar" />
                        <include name="lib/**/*.jar" />
                </fileset>
        </path>

and build.properties defines

# The path to cobertura.jar
cobertura.dir=../..



On Thu, Mar 19, 2009 at 5:08 AM, John W. Lewis <JohnW.Lewis@sas.com> wrote:

 

You need the log4j jar in the same directory you have cobertura.jar.

 

From: Chris Stoughton [mailto:chris.stoughton@gmail.com]
Sent: Wednesday, March 18, 2009 10:42 PM
To: cobertura-devel@lists.sourceforge.net
Subject: [Cobertura-devel] examples/basic problem

 

I downloaded cobertura-1.9.1 and cobertura-1.8.1 and for both versions, in examples/basic, running ant has the same problem:

 $ ant
Buildfile: build.xml

init:
    [mkdir] Created dir: /afs/fnal.gov/files/home/room3/stoughto/cobertura-1.9.1/examples/basic/instrumented

compile:

instrument:
   [delete] Deleting directory /afs/fnal.gov/files/home/room3/stoughto/cobertura-1.9.1/examples/basic/instrumented

BUILD FAILED
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at net.sourceforge.cobertura.util.CommandLineBuilder.<clinit>(CommandLineBuilder.java:76)
        at net.sourceforge.cobertura.ant.InstrumentTask.execute(InstrumentTask.java:154)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
        at org.apache.tools.ant.Main.runBuild(Main.java:758)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 19 more

Total time: 0 seconds
-bash-3.00$ java -version
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)
-bash-3.00$ ant -version
Apache Ant version 1.7.1 compiled on June 27 2008
-bash-3.00$

I'm  using a local install of java, with the file downloaded from Sun:  jdk-6u12-linux-i586.bin

What can I do to diagnose this issue?