You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Witham, Darren (Contractor)" <wi...@bp.com> on 2003/03/06 18:13:38 UTC

Custom Task Error

Hi,

  I am working with a very large generated build file and have had the need to write an Ant task to ping Weblogic and continue when it is up.

  I have written a simple user task that has about 3 lines in the execute method. I have made use of a Weblogic class to connect to the server (T3Client). This code works fine when I just run it from my IDE however when I run it as an Ant task i.e set up task in build file and invoke it - the code doesn't work. I am supplying the correct classpath's etc as the stacktrace shows the error occuring within the T3Client code...

[wlping] java.lang.ExceptionInInitializerError: java.lang.NullPointerException
[wlping]     at weblogic.utils.classloaders.ServletClassFinder.<init>(ServletClassFinder.java:32)
[wlping]     at weblogic.j2ee.ApplicationManager.getFinder(ApplicationManager.java:283)
[wlping]     at weblogic.j2ee.ApplicationManager.loadFromNetwork(ApplicationManager.java:261)
[wlping]     at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:194)
[wlping]     at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:106)
[wlping]     at weblogic.rmi.internal.ClientRuntimeDescriptor.computeInterfaces(ClientRuntimeDescriptor.java:218)
[wlping]     at weblogic.rmi.internal.ClientRuntimeDescriptor.intern(ClientRuntimeDescriptor.java:111)
[wlping]     at weblogic.rmi.internal.dgc.DGCClientImpl.<clinit>(DGCClientImpl.java:66)
[wlping]     at weblogic.rmi.internal.RMIKernelService.initialize(RMIKernelService.java:13)
[wlping]     at weblogic.kernel.Kernel.initialize(Kernel.java:159)
[wlping]     at weblogic.kernel.Kernel.ensureInitialized(Kernel.java:101)
[wlping]     at weblogic.common.T3Client.<init>(T3Client.java:215)
[wlping]     at weblogic.common.T3Client.<init>(T3Client.java:263)
[wlping]     at weblogic.common.T3Client.<init>(T3Client.java:316)
[wlping]     at com.bp.ist.tools.wlping.WLPing.doPing(WLPing.java:88)
[wlping]     at com.bp.ist.tools.wlping.WLPing.execute(WLPing.java:158)
[wlping]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:104)
[wlping]     at org.apache.tools.ant.Task.perform(Task.java:217)
[wlping]     at org.apache.tools.ant.Target.execute(Target.java:184)
[wlping]     at org.apache.tools.ant.Target.performTasks(Target.java:202)
[wlping]     at org.apache.tools.ant.Project.executeTarget(Project.java:601)
[wlping]     at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:266)
[wlping]     at org.apache.tools.ant.Task.perform(Task.java:217)
[wlping]     at org.apache.tools.ant.Target.execute(Target.java:184)
[wlping]     at org.apache.tools.ant.Target.performTasks(Target.java:202)
[wlping]     at org.apache.tools.ant.Project.executeTarget(Project.java:601)
[wlping]     at org.apache.tools.ant.Project.executeTargets(Project.java:560)

It would appear to be some sort of path problem. I decided to call the code via <java classname="com.bp.ist.tools.wlping.WLPing">. This works but I notice an  Ant classloader/nullpointer exception of some description occurs unless I set fork="true" (which is no good for me).

Without knowing what the T3Client code does, are there any obvious reasons why working code should fall over when placed in a user written task or why just running the code via <java...> would appear to effect Ant after it returns unless it is run in another JVM ?

Thx

Re: Custom Task Error

Posted by Mike McNally <m5...@works.com>.
> Without knowing what the T3Client code does, are there any obvious
> reasons why working code should fall over when placed in a user
> written task or why just running the code via <java...> would
> appear to effect Ant after it returns unless it is run in another
> JVM ?

Class loader issues can cause that.  The second possibility you
describe is almost certainly impossible, unless the program in 
the other JVM writes files the Ant process later picks up.

Ant will load your task code via the system classloader if your
task code is on your system classpath.  If not, then it loads
it with an instance of AntClassLoader.  If your weblogic stuff
has its own class loader (probably does), then strange things
can happen at the boundaries.

Try adding debug code to your Ant task class like this:

  log("Loader is: " + this.getClass().getClassLoader().getClass().getName());


--
[ you are my main foo ] Mike McNally -- m5@works.com