ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: strange logging error
Date Tue, 23 Aug 2005 12:03:42 GMT
Maybe the project is not set correctly.
What does "getProject()" refer?

If you inherit from DispatchUtils, you dont have a real task (class inherited from oata.Task).
You┬┤re using a task wrapper instead.


Jan



>-----Urspr├╝ngliche Nachricht-----
>Von: Kev Jackson [mailto:kevin.jackson@it.fts-vn.com] 
>Gesendet: Dienstag, 23. August 2005 12:23
>An: Ant Developers List
>Betreff: strange logging error
>
>Hi all,
>
>I'm writing a custom task at the moment and I've come across a problem
>
>the simple act of trying to log causes a NullPointerException at
>Task:347 which seems to be failing as the project is null.
>
>I'm pretty sure that this is being caused by my code, but I 
>can't see what the problem is at all:
><build.xml>
>
><?xml version="1.0"?>
>
><project name="darcs" default="test" basedir=".">
>
>    <target name="test">
>        <echo message="Ant setup correctly" />
>    </target>
>
>
>    <target name="test-darcs">
>        <taskdef name="darcs"
>                 
>classname="org.apache.tools.ant.taskdefs.optional.darcs.Darcs" />
>         
>     <darcs command="initialize" />
>    </target>
></project>
>for simplicity I'm writing within the ant codebase, later I'll 
>break it out into a separate jar
>
>class that fails
>
>package org.apache.tools.ant.taskdefs.optional.darcs.commands;
>
>import java.io.IOException;
>
>import org.apache.tools.ant.BuildException;
>import org.apache.tools.ant.taskdefs.Execute;
>import org.apache.tools.ant.taskdefs.optional.darcs.AbstractDarcs;
>
>public class Initialize extends AbstractDarcs implements DarcsCommand {
>   
>    private boolean pristineTree = true;
>    private static final String PRISTINE = "--plain-pristine-tree";
>    private static final String NO_PRISTINE = "--no-pristine-tree";
>   
>    /**
>     * set to use the pristine tree option
>     * @param pristineTree
>     */
>    public void setPristineTree(final boolean pristineTree) {
>        this.pristineTree = pristineTree;
>    }
>
>    public void execute() throws BuildException {
>        String[] cmdline;
>        if (pristineTree) {
>            cmdline = 
>createCommandline(DarcsCommandList.DARCS, new String[] 
>{DarcsCommandList.INITIALIZE, PRISTINE});
>        } else {
>            cmdline = 
>createCommandline(DarcsCommandList.DARCS, new String[] 
>{DarcsCommandList.INITIALIZE, NO_PRISTINE});
>        }
>        Execute exe = new Execute(getExecuteStreamHandler(), null);
>        exe.setCommandline(cmdline);
>        try {
>            if(verbose) {
>                log("Executing : "+this); <-- this breaks with 
>NullPointerException
>            }
>            exe.execute();
>        } catch (IOException e) {
>            throw new BuildException("There was a problem 
>executing the command [ "+this.toString()+" ]");
>        }
>    }
>}
>
>annoyingly the code works as intended without the logging, I 
>just don't know why it can't find the project when getProject 
>is called in the Task superclass.
>
>with -verbose on, I get a message about antlib.xml not found, 
>but that should have nothing to do with this.
>
>just for completeness, here's my stack trace:
>
>BUILD FAILED
>D:\eclipse\WORKSP~1\ant\darcs.xml:14: java.lang.NullPointerException
>        at
>org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
>a:114)
>        at org.apache.tools.ant.Task.perform(Task.java:365)
>        at org.apache.tools.ant.Target.execute(Target.java:356)
>        at org.apache.tools.ant.Target.performTasks(Target.java:384)
>        at
>org.apache.tools.ant.Project.executeSortedTargets(Project.java:1236)
>        at 
>org.apache.tools.ant.Project.executeTarget(Project.java:1205)
>        at
>org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
>cutor.java:40)
>        at 
>org.apache.tools.ant.Project.executeTargets(Project.java:1088)
>        at org.apache.tools.ant.Main.runBuild(Main.java:676)
>        at org.apache.tools.ant.Main.startAnt(Main.java:195)
>        at org.apache.tools.ant.Main.start(Main.java:158)
>        at org.apache.tools.ant.Main.main(Main.java:236)
>Caused by: java.lang.NullPointerException
>        at org.apache.tools.ant.Task.log(Task.java:347)
>        at org.apache.tools.ant.Task.log(Task.java:335)
>        at
>org.apache.tools.ant.taskdefs.optional.darcs.commands.Initialize.exec
>ute(Initialize.java:34)
>        at
>org.apache.tools.ant.taskdefs.optional.darcs.Darcs.execute(Darcs.java
>:19)
>        at
>org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>        at 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>        at java.lang.reflect.Method.invoke(Unknown Source)
>        at
>org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
>a:104)
>        ... 11 more
>--- Nested Exception ---
>java.lang.NullPointerException
>        at org.apache.tools.ant.Task.log(Task.java:347)
>        at org.apache.tools.ant.Task.log(Task.java:335)
>        at
>org.apache.tools.ant.taskdefs.optional.darcs.commands.Initialize.exec
>ute(Initialize.java:34)
>        at
>org.apache.tools.ant.taskdefs.optional.darcs.Darcs.execute(Darcs.java
>:19)
>        at
>org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>        at 
>sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>        at java.lang.reflect.Method.invoke(Unknown Source)
>        at
>org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
>a:104)
>        at org.apache.tools.ant.Task.perform(Task.java:365)
>        at org.apache.tools.ant.Target.execute(Target.java:356)
>        at org.apache.tools.ant.Target.performTasks(Target.java:384)
>        at
>org.apache.tools.ant.Project.executeSortedTargets(Project.java:1236)
>        at 
>org.apache.tools.ant.Project.executeTarget(Project.java:1205)
>        at
>org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
>cutor.java:40)
>        at 
>org.apache.tools.ant.Project.executeTargets(Project.java:1088)
>        at org.apache.tools.ant.Main.runBuild(Main.java:676)
>        at org.apache.tools.ant.Main.startAnt(Main.java:195)
>        at org.apache.tools.ant.Main.start(Main.java:158)
>        at org.apache.tools.ant.Main.main(Main.java:236)
>
>Total time: 0 seconds
>
>My guess is that I'm doing something incredibly stupid, but I 
>thought you might see a problem within the code - using latest 
>CVS version
>
>Thanks for any help
>Kev
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For 
>additional commands, e-mail: dev-help@ant.apache.org
>
>

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


Mime
View raw message