1

I'm trying Groovy for third time, and again, I've run into classloading problems.

I have a script which uses HTMLUnit (so it has it on classpath with it's transitive deps). Groovy is on classpath as groovy-all.jar. When I run the script, I get this:

Caught: java.lang.LinkageError: loader constraint violation: loader (instance of ) previously initiated loading for a different type with name "org/w3c/dom/NamedNodeMap"

Do I need to cut HTMLUnit's deps away, or is there a way to tell Groovy to use what's on classpath? Some switch which would mean, "don't complain about duplicite class appearance" or such.

Thanks.

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277

1 Answers1

1

Not related to Groovy, the problem is that HTMLUnit depends on xercesImpl (see http://htmlunit.sourceforge.net/dependencies.html) and the JDK comes with it as well:

see

http://xml.apache.org/xalan-j/faq.html#faq-N100EF and

XercesImpl in conflict with JavaSE 6's internal xerces implementation. Both are needed... what can be done?

Community
  • 1
  • 1
Andre Steingress
  • 4,381
  • 28
  • 28
  • Interesting, when I run HTMLUnit app without groovy, it works... How is that? – Ondra Žižka May 05 '11 at 01:30
  • How did you include HTMLUnit? I tested it on Groovy 1.7 in groovyConsole with the following code snippet, and it worked: `@Grab('net.sourceforge.htmlunit:htmlunit:2.6') import com.gargoylesoftware.htmlunit.WebClient def client = new WebClient() def page = client.getPage('http://www.google.com') assert 'Google' == page.titleText println 'done without error' ` – Andre Steingress May 05 '11 at 05:05