开发者

Groovy, java.lang.LinkageError problem with Executors and HttPBuilder

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开发者_如何学JAVA said the strange fact is it happens a lot of times but not always.

Thanks for the help


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜