Hi,
I am running the following code to run this ant file.
private void antRun(){
File buildFile = new File("C:\\Documents and Settings\\tharanga\\My
Documents\\IBM\\wssitedev51\\workspace\\BundleDeployer\\build.xml");
if(buildFile.exists()){
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_DEBUG);
p.addBuildListener(consoleLogger);
try {
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
}
catch (BuildException e) {
p.fireBuildFinished(e);
}
} else {
System.out.println(buildFile.getAbsolutePath()+" does not exists");
}
After the verbose mode I recived the stacktrace as follows.
BUILD FAILED
C:\Documents and Settings\tharanga\My
Documents\IBM\wssitedev51\workspace\BundleDeployer\build.xml:19:
java.lang.NullPointerException
at org.apache.tools.ant.Task.perform(Task.java:373)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at oulu.info.test.Runner.antRun(Runner.java:52)
at oulu.info.test.Runner.run(Runner.java:67)
at java.lang.Thread.run(Thread.java:513)
--- Nested Exception ---
java.lang.NullPointerException
at
com.ibm.ive.eccomm.bde.tooling.SourceBundle.getStagingDirectory(SourceBundle.java:54)
at
com.ibm.ive.eccomm.bde.ui.tooling.ant.SubmitBundle.execute(SubmitBundle.java:57)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at oulu.info.test.Runner.antRun(Runner.java:52)
at oulu.info.test.Runner.run(Runner.java:67)
at java.lang.Thread.run(Thread.java:513)
Total time: 8 seconds
Hello,
how do you run this programmatically ?
one common source of null pointer exceptions in Ant API use is to forget to set
a project reference on task objects or datatypes. The null pointer exception
happens then as soon as the task or the datatype tries to log something.
if you have a NPE when using command line Ant, run
ant -verbose
(-verbose is a command line argument)
this will give you a stack trace.
Regards,
Antoine
-------- Original-Nachricht --------
Datum: Mon, 16 Oct 2006 17:41:07 +0300
Von: "tharanga wijethilake" <[EMAIL PROTECTED]>
An: "Ant Users List" <[email protected]>
Betreff: How to resolve a NullPointerException
> Hi all,
> I am tring to run this Ant file using a java program.
> When I run this using "Ant run" option provided in eclipse it runs with
> out any trouble.
> <project name="bundleRunner" default="submit_a_bundle" basedir=".">
>
> <property name="ant.classpath" location="lib"/>
>
> <taskdef name="smfbd.submitJarBundle"
> classname="com.ibm.ive.eccomm.bde.ui.tooling.ant.SubmitJarBundle">
>
> <classpath>
>
> <fileset dir="lib">
>
> <include name="${ant.classpath}/smfbdTasks.jar"/>
>
> <include name="${ant.classpath}/bde.jar"/>
>
> </fileset>
>
> </classpath>
>
> </taskdef>
>
> <target name="submit_a_bundle">
>
> <smfbd.submitJarBundle bundlepath="/HelloWorld" replace="true">
>
> <bundleserver host="localhost" user="Admin" password="Admin" port="8080"
> webapp="/smf"/>
>
> </smfbd.submitJarBundle>
>
> </target>
>
> </project>
>
>
> but when I try to run prgrammtically it gives a null pointer. Please Could
> someone tell me how am i supose to find from where the exception throws.
> submit_a_bundle:
>
> BUILD FAILED
>
> C:\Documents and Settings\tharanga\My
> Documents\IBM\wssitedev51\workspace\AntRunner\build.xml:12:
> java.lang.NullPointerException
>
> Total time: 2 seconds
>
>
> It is line 12 but is it the "bundlepath" or is it because of the related
> class file for smfbd task is missing. Thank you very much.
>
>
>