In my
Ant build scripts, I often access environment variables:
...
<property environment="env" />
...
<available classname="junit.framework.TestCase"
classpath="${env.ANT_HOME}/lib/junit.jar"
property="junit.present" />
<echo message="junit.present = ${junit.present}" />
...
When running such a build script in Eclipse, a NullPointerException is
reported at the line that declares the property for accessing the
environment:
--- BEGIN EXCEPTION ---
C:\projects\schemaloader\build.xml:6: java.lang.NullPointerException
at org.apache.tools.ant.ProjectHelper.parse(ProjectHelper.java:135)
at
org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:85)
at
org.eclipse.ant.internal.core.ant.InternalAntRunner.parseScript(InternalAntR
unner.java:237)
at
org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.ja
va:259)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:188)
at
org.eclipse.ui.externaltools.internal.core.AntFileRunner.execute(AntFileRunn
er.java:58)
at
org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.executeRunne
r(DefaultRunnerContext.java:334)
at
org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.run(DefaultR
unnerContext.java:384)
at
org.eclipse.ui.externaltools.internal.ui.AntLaunchWizard$1.run(AntLaunchWiza
rd.java:116)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext
.java:98)
--- Nested Exception ---
java.lang.NullPointerException
at
org.apache.tools.ant.taskdefs.Property.loadEnvironment(Property.java:253)
at org.apache.tools.ant.taskdefs.Property.execute(Property.java:183)
at
org.apache.tools.ant.ProjectHelper$TaskHandler.finished(ProjectHelper.java:4
85)
at
org.apache.tools.ant.ProjectHelper$AbstractHandler.endElement(ProjectHelper.
java:204)
at
org.xml.sax.helpers.XMLReaderAdapter.endElement(XMLReaderAdapter.java:347)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1536)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
at org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:314)
at org.apache.tools.ant.ProjectHelper.parse(ProjectHelper.java:117)
at
org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:85)
at
org.eclipse.ant.internal.core.ant.InternalAntRunner.parseScript(InternalAntR
unner.java:237)
at
org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.ja
va:259)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:188)
at
org.eclipse.ui.externaltools.internal.core.AntFileRunner.execute(AntFileRunn
er.java:58)
at
org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.executeRunne
r(DefaultRunnerContext.java:334)
at
org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.run(DefaultR
unnerContext.java:384)
at
org.eclipse.ui.externaltools.internal.ui.AntLaunchWizard$1.run(AntLaunchWiza
rd.java:116)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext
.java:98)
Build exception: C:\projects\schemaloader\build.xml:6:
java.lang.NullPointerException
--- END EXCEPTION ---
When running this script outside of Eclipse, there are no problems.
Development environment:
- Windows XP Professional
- Eclipse R2.0
- Installed Java SDKs: 1.3.1_03, 1.4.0_01
- Ant used externally from Eclipse: 1.4.1, 1.5
I have searched newsgroups and FAQs. I hope that I have done so adequately
and have not wasted anyone's time here.
Thanks,
Craig