I am trying to run a script in Ant and I am running into an issue related to class loaders and class paths. Here're the specifics of my script
<taskdef name="jmxInvoke" classname="org.apache.catalina.ant.jmx.JMXAccessorInvokeTask" classpath=${someClassPath} />
<script language="javascript>
importClass(org.apache.catalina.ant.jmx.Arg);
var jmxInvokeTask = project.createTask("aJMXInvokeAntTask")
var someArg = new Arg();
someArg.setValue("someValue");
someTask.addArg(someArg);
</script>
When I have "catalina-ant.jar" in my ANT_HOME/lib, the above script runs fine. I am trying to update the script with the assumption that I cannot copy catalina-ant.jar to ANT_HOME/lib in other environments. Hence I was trying to find a way where I have the catalina-ant.jar available to the classpath when this script is run. As a result I tried to specify the classpath during which I get an exception saying there is no such "addArg" method in "jmxInvokeTask" which takes an argument of type "Arg". This was very confusing to me, since JMXAccessorInvokeTask does have this method. As I looked deeper, I found that Ant uses a different classloader when we specify a classpath. Also, when I did a comparison of the class loaders, it seems like there are two different class loaders used when we call "project.createTask" and when we say something like "new Arg()". Has anyone else solved this problem? Thanks.