2

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

res1
  • 3,482
  • 5
  • 29
  • 50
  • It seems to be some sort of ClassLoader problem. Have you tried it with the code as a class instead of a script? Also, what version of Groovy are you using? It's always possible that you've found a bug, but it would be hard to confirm without knowing the exact version. – Matt Passell Mar 08 '11 at 00:55
  • @MattPassel I asked the same question on groovy's mailing list and seems a bug. I reported it [jira link](http://jira.codehaus.org/browse/GROOVY-4623) – res1 Mar 08 '11 at 23:21

1 Answers1

1

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

Lifeweaver
  • 986
  • 8
  • 29
blackdrag
  • 6,413
  • 2
  • 26
  • 38