Groovy、Executors 和 HttPBuilder 的 java.lang.LinkageError 问题
我有这个测试代码:
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.1' )
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import groovyx.net.http.HTTPBuilder
ExecutorService executor = Executors.newCachedThreadPool()
(1..10).each {
executor.execute(new Runnable(){
void run() {
def http = new HTTPBuilder('http://www.google.com')
}
})
}
executor.shutdown()
大多数时候,但并非总是我得到一个 LinkageError
Exception in thread "pool-1-thread-8" java.lang.LinkageError: loader (instance of org/codehaus/groovy/tools/RootLoader): attempted duplicate class definition for name: "org/apache/commons/logging/impl/LogFactoryImpl"
在这个例子中,我使用 Grape,但我尝试将 HttbBuilder 的 jar 直接添加到类路径中,我也遇到了同样的问题。
可以通过某种方式解决吗? 正如我所说,奇怪的事实是这种情况发生很多次,但并非总是如此。
感谢您的帮助
i have this test code:
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.1' )
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import groovyx.net.http.HTTPBuilder
ExecutorService executor = Executors.newCachedThreadPool()
(1..10).each {
executor.execute(new Runnable(){
void run() {
def http = new HTTPBuilder('http://www.google.com')
}
})
}
executor.shutdown()
most of the times, but not always i get a LinkageError
Exception in thread "pool-1-thread-8" java.lang.LinkageError: loader (instance of org/codehaus/groovy/tools/RootLoader): attempted duplicate class definition for name: "org/apache/commons/logging/impl/LogFactoryImpl"
In this example i am using Grape, but i tried by adding the jars of HttbBuilder directly to classpath too and i get the same problem.
It is possible to resolve in some way?
As i said the strange fact is it happens a lot of times but not always.
Thanks for the help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我喜欢指出 https://issues.apache.org/jira/browse/GROOVY -3495 对于这个问题。如果修复有效,则此处报告的问题已在 1.8.2、1.9-beta-3 和 1.7.11 中修复。除 1.7.11 外,所有版本均已发布
I like to point to https://issues.apache.org/jira/browse/GROOVY-3495 for this issue. If the fix there works, then the issue reported here is fixed in 1.8.2, 1.9-beta-3 and 1.7.11. Releases has been done for all of them but 1.7.11 by now