You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by James Huang <ju...@hotmail.com> on 2004/08/07 20:53:14 UTC

Help: NPE from DefBase.java

This test program fails with Ant-1.6.2 but works with Ant-1.5.4:

8< ------------------------------------------------------
import org.apache.tools.ant.*;

public class AntTest
{
  public static void main(String args[]) {
    try {
      Project proj = new Project();
      proj.init();
      proj.addBuildListener(new DefaultLogger());

      Task task = proj.createTask("taskdef");
      IntrospectionHelper helper = 
IntrospectionHelper.getHelper(task.getClass());

      helper.setAttribute(proj, task, "name", "judo");
      helper.setAttribute(proj, task, "classname", 
"com.judoscript.AntJudoScriptTask");

      task.execute();

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}
------------------------------------------------------ >8

java.lang.NullPointerException
        at 
org.apache.tools.ant.taskdefs.DefBase.createLoader(DefBase.java:132)
        at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:169)
        at AntTest.main(AntTest.java:17)

In DefBase.java:
    protected ClassLoader createLoader() {
        if (getAntlibClassLoader() != null) {
            return getAntlibClassLoader();
        }
        if (createdLoader == null) {
            createdLoader = this.cpDelegate.getClassLoader(); <-- line 132

However, the build.xml works with both Ant-1.6.2/1.5.4:

<project>
  <taskdef name="judo" classname="com.judoscript.AntJudoScriptTask"/>
</project>

I don't know if it's a bug or something extra I need to do in 1.6.2. Please 
advise.

Thanks,
-James



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org