在Grails分叉JVM中使用ant sshexec()

在Grails分叉JVM中使用ant sshexec(),grails,Grails,我在使用Grails(版本2.3及以上)附带的分叉JVM环境时遇到了一个问题。没有分叉环境,一切都正常工作,我只是想了解是什么原因导致它启用后无法正常工作。我试图通过Groovy的AntBuilderhelper类在远程服务器上执行命令。sshexec()方法继续抛出一个错误,因为它找不到sshexec所需的jar(我为它添加了一个依赖项) 我可以运行类似于ant.echo(“hello”)ok的东西,所以它似乎与sshexec相关。我正在使用BuildConfig.groovy中的默认设置:

我在使用Grails(版本2.3及以上)附带的分叉JVM环境时遇到了一个问题。没有分叉环境,一切都正常工作,我只是想了解是什么原因导致它启用后无法正常工作。我试图通过Groovy的
AntBuilder
helper类在远程服务器上执行命令。
sshexec()
方法继续抛出一个错误,因为它找不到sshexec所需的jar(我为它添加了一个依赖项)

我可以运行类似于
ant.echo(“hello”)
ok的东西,所以它似乎与sshexec相关。我正在使用
BuildConfig.groovy
中的默认设置:

grails.project.fork = [
    // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
    //  compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

    // configure settings for the test-app JVM, uses the daemon by default
    test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
    // configure settings for the run-app JVM
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    // configure settings for the run-war JVM
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    // configure settings for the Console UI JVM
    console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
如果我对这一部分进行注释,消除分叉执行环境,那么一切都很好。我知道分叉JVM将构建类路径与运行时类路径隔离开来。这会阻止Grails引入所需的依赖项吗?不确定为什么只注释掉
grails.project.fork
就可以修复所有问题。谢谢

编辑:

以下是我的依赖项:

dependencies {
    // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
    runtime 'mysql:mysql-connector-java:5.1.24'

    runtime "com.jcraft:jsch:0.1.46"
    runtime "org.apache.ant:ant-jsch:1.8.2"
}
还有一个例外:

Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec 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

我怀疑在运行非forked时,而不是在运行forked时,在父类加载器的某个地方有jsch JAR(这是sshexec所必需的)——尝试添加一个显式的
compile
runtime
依赖项,我已经将我的依赖项添加到问题中以供参考——我一直在运行时要求jsch。原始异常的堆栈跟踪
e
是否提供了任何线索?哇,真不敢相信我忘记检查了!看起来它找不到罐子。我的依赖项有问题吗?它们不应该在运行时拉进来吗?
Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec 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