ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Huang" <judoscr...@hotmail.com>
Subject Help: NPE from DefBase.java
Date Sat, 07 Aug 2004 18:53:14 GMT
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


Mime
View raw message