Hi all,
I'm trying to create a custom task that make some transformations using Javassist (actually, this is my first Ant task). The task is very simple, but can't figure out why it always produces a java.lang.NoClassDefFoundError (since the corresponding jar is in the path as message shows). I'm running inside Eclipse The code is below, could anybody help me? Thanks, Andre public class TransformerTask extends Task { private String transformerClassName = Transformer.class.getName(); private Path classpath; public void setClasspath(Path classpath) { this.classpath = classpath; } public Path createClasspath() { if (this.classpath == null) { this.classpath = new Path(getProject()); } return this.classpath.createPath(); } public void setClasspathRef(Reference r) { createClasspath().setRefid(r); } public Path getClasspath() { return classpath; } private Transformer getTransformer() throws BuildException { Transformer transformer = null; try { Class<?> dc; if (classpath != null) { System.out.println("CLASSPATH: " + classpath); log("Loading " + transformerClassName + " using AntClassLoader with classpath " + classpath, Project.MSG_VERBOSE); AntClassLoader loader = getProject().createClassLoader(classpath); dc = loader.loadClass(transformerClassName); } else { log("Loading " + transformerClassName + " using system loader.", Project.MSG_VERBOSE); dc = Class.forName(transformerClassName); } transformer = (Transformer) dc.newInstance(); } catch (ClassNotFoundException e) { throw new BuildException("Class Not Found: Transformer " + transformerClassName + " could not be loaded", e, getLocation()); } catch (IllegalAccessException e) { throw new BuildException("Illegal Access: Transformer " + transformerClassName + " could not be loaded", e, getLocation()); } catch (InstantiationException e) { throw new BuildException("Instantiation Exception: Transformer " + transformerClassName + " could not be loaded", e, getLocation()); } return transformer; } public void execute() throws BuildException { Transformer transformer = getTransformer(); transformer.transform(null); } } <project default="jeha"> <path id="jeha.classpath"> <fileset dir="lib" includes="*.jar"/> </path> <taskdef name="jeha" classname="org.codecompany.jeha.util.TransformerTask"/> <target name="jeha"> <jeha classpathref="jeha.classpath"/> </target> </project> Buildfile: C:\Andre\Projetos\Teste\build.xml jeha: [jeha] CLASSPATH: C:\Andre\Projetos\Teste\lib\ant.jar;C:\Andre\Projetos\Teste\lib\commons-logg ing-1.0.4.jar;C:\Andre\Projetos\Teste\lib\javassist-3.9.jar;C:\Andre\Projeto s\Teste\lib\log4j-1.2.15.jar;C:\Andre\Projetos\Teste\lib\retroweaver-all-2.0 .7.jar BUILD FAILED C:\Andre\Projetos\Teste\build.xml:9: java.lang.NoClassDefFoundError: javassist/ClassPool Total time: 203 milliseconds