0
votes

I'm trying to use Ant to run PMD, but it tells me that it can't find the Objectweb asm classes. Specifically:

build.xml:526: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor

I have the objectweb-asm package installed, with the jar files in /usr/share/java/objectweb-asm. I made symbolic links to the asm jar files from ~/.ant/lib/, but that doesn't change anything. Nor does making symbolic links to the jar file from inside /usr/share/java.

So, how do I make this work?

I'm using PMD 4.2.5, Ant 1.8.4, and objectweb-asm 3.3.1-7

The full error message from Ant:

.../build.xml:526: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
    at net.sourceforge.pmd.typeresolution.ClassTypeResolver.<init>(ClassTypeResolver.java:136)
    at net.sourceforge.pmd.typeresolution.TypeResolutionFacade.initializeWith(TypeResolutionFacade.java:15)
    at net.sourceforge.pmd.sourcetypehandlers.JavaTypeHandler$3.start(JavaTypeHandler.java:35)
    at net.sourceforge.pmd.PMD.processFile(PMD.java:118)
    at net.sourceforge.pmd.PMD.processFile(PMD.java:75)
    at net.sourceforge.pmd.PMD.processFile(PMD.java:210)
    at net.sourceforge.pmd.PMD$PmdRunnable.call(PMD.java:469)
    at net.sourceforge.pmd.PMD$PmdRunnable.call(PMD.java:427)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassVisitor
    at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1365)
    at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1315)
    at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1068)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 12 more
1
Can we see the ant build file. - mikemil

1 Answers

0
votes

Turns out the problem is that PMD is expecting the main Objectweb asm jar file to be named asm-3.3.1.jar, when it's actually asm.jar. A simple soft link solved the problem.