Groovy、Executors 和 HttPBuilder 的 java.lang.LinkageError 问题

发布于 2024-10-09 15:44:18 字数 904 浏览 5 评论 0原文

我有这个测试代码:

@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

殤城〤 2024-10-16 15:44:19

我喜欢指出 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文