Note that there are some explanatory texts on larger screens.

plurals
  1. POGroovy with Grape and AntBuilder classloader problem
    primarykey
    data
    text
    <p>I wanted to use groovy for a little ftp script and found this post <a href="http://www.hhhhq.org/blog/2009/05/01/ftp-using-groovy-and-ant/" rel="noreferrer">http://www.hhhhq.org/blog/2009/05/01/ftp-using-groovy-and-ant/</a> Since there were several dependencies I wanted to use Grape. All dependencies are resolved and present in the cache. But I can't get Ant to find the optional tasks in the other libs. It always says</p> <pre><code>Caught: : Problem: failed to create task or type ftp Cause: the class org.apache.tools.ant.taskdefs.optional.net.FTP was not found. This looks like one of Ant's optional components. Action: Check that the appropriate optional JAR exists in -ANT_HOME\lib -the IDE Ant configuration dialogs Do not panic, this is a common problem. The commonest cause is a missing JAR. This is not a bug; it is a configuration problem at GrabTest.runMe(GrabTest.groovy:15) at GrabTest.run(GrabTest.groovy:26) </code></pre> <p>Groovy Version: 1.6.5 JVM: 1.6.0_15</p> <p>Here is my source code</p> <pre><code>@Grab(group='ant', module='ant', version='[1.6.5,)') @Grab(group='ant', module='ant-nodeps', version='[1.0,)') @Grab(group='ant', module='ant-apache-oro', version='[1.0,)') @Grab(group='ant', module='ant-commons-net', version='[1.0,)') @Grab(group='apache-oro', module='jakarta-oro', version='[2.0.8,)') @Grab(group='commons-net', module='commons-net', version='[1.4,)') def runMe() { // works println getClass().getClassLoader().loadClass("org.apache.tools.ant.taskdefs.optional.net.FTP") def ant = new AntBuilder() println getClass().getClassLoader() //groovy.lang.GroovyClassLoader$InnerLoader println ant.getClass().getClassLoader() //org.codehaus.groovy.tools.RootLoader ant.ftp( server:"ftp.foo.com", userid:"user", password:"passwd", passive:"yes", verbose:"yes", remotedir:"/pub/incoming", binary:"yes" ) { fileset( dir:"." ) { include( name:"**/*.gz" ) } } } runMe() </code></pre> <p>As you can see I suspect the classloader of being the problem, it seems that Grape doesn't inject the dependencies there. Any idea of how I can get it to work?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload