Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
java exception when task executed with ant but not manually

java exception when task executed with ant but not manually

2007-05-15       - By David Wood
Reply:     1     2     3     4     5  

Hello users,

I am getting different results when executing a java program with ant than
when I execute it manually.

When ant is used the program throws a null pointer exception eg:

[d.wood@(protected)]$ ant testApp
Buildfile: build.xml

init:

compile:

testApp:
    [java] getting frontpage
    [java] Got 30 frontpage entries
    [java] java.lang.NullPointerException
    [java]     at GetReactomeData.main(Unknown Source)
    [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
    [java]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
    [java]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
    [java]     at java.lang.reflect.Method.invoke(Method.java:585)
    [java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:202)
    [java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:134)
    [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
    [java]     at
org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
    [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
    [java]     at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    [java]     at org.apache.tools.ant.Task.perform(Task.java:364)
    [java]     at org.apache.tools.ant.Target.execute(Target.java:341)

But when I launch the application manually it does not crash and completes
fine.
[d.wood@(protected) build]$ java RunApp
getting frontpage
Got 30 frontpage entries
109581  (Pathway)       Apoptosis (parent = null)
69620   (Pathway)       Cell Cycle Checkpoints (parent = null)
69278   (Pathway)       Cell Cycle, Mitotic (parent = null)
73894   (Pathway)       DNA Repair (parent = null)
69306   (Pathway)       DNA Replication (parent = null)
163200  (Pathway)       Electron Transport Chain (parent = null)
.etc


In both cases the CLASSPATH is set the same (I have compared these by
outputting it within the script before it crashes).  The application is
attempting to access data stored within deserialised java beans from a web
services server, might this be breaking the ant VM?

My testApp task is:
<!-- testApp -->
<target name="testApp" depends="compile"
   description="run a direct test of the java app">    
   <java classname="RunApp">
     <classpath>
  <pathelement path="${env.CLASSPATH}:${build}"/>
  <fileset dir="${build}">
   <include name="RunApp"/>
  </fileset>
     </classpath>
   </java>
 </target>


Thanks for any help!

Cheers,
Dave



©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.