Grails
  1. Grails
  2. GRAILS-8819

loader constraint violation: Problem while using xerces 2.9.1

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.1, 2.2-RC1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows Vista, Spring STS, java 1.6.17

      Description

      While using xerces (2.9.1) Grails throw an exception:

      There is an easy way to reproduce this error:

      in grails-app/conf/BuildConfig.groovy

      enable maven repository - mavenCentral()

      and add dependencies: runtime 'xerces:xercesImpl:2.9.1'

      run grails run-war: an exception is thrown:

      java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
      at java.lang.Class.getDeclaredMethods(Class.java:1791)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:33)
      at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:20)
      at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy:106)
      at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy)
      at grails.util.PluginBuildSettings$getPluginInfos.callCurrent(Unknown Source)
      at grails.util.PluginBuildSettings.getPluginInfo(PluginBuildSettings.groovy:141)
      at grails.util.PluginBuildSettings$getPluginInfo.callCurrent(Unknown Source)
      at grails.util.PluginBuildSettings.getPluginInfoForSource(PluginBuildSettings.groovy:169)
      at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:303)
      at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:820)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:513)
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:489)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:466)
      at _GrailsEvents_groovy.run(_GrailsEvents_groovy:54)
      at _GrailsEvents_groovy$run.call(Unknown Source)
      at _GrailsClean_groovy$run.call(Unknown Source)
      at _GrailsClean_groovy.run(_GrailsClean_groovy:29)
      at _GrailsClean_groovy$run.call(Unknown Source)
      at _GrailsWar_groovy$run.call(Unknown Source)
      at _GrailsWar_groovy.run(_GrailsWar_groovy:33)
      at _GrailsWar_groovy$run.call(Unknown Source)
      at RunWar.run(RunWar.groovy:29)
      at RunWar$run.call(Unknown Source)
      at gant.Gant.processTargets(Gant.groovy:494)
      at gant.Gant.processTargets(Gant.groovy:480)
      Error loading event script from file [C:\Users\Bartek\.grails\1.2.0.RC1\projects\testGrailsRc1\plugins\tomcat-1.2.0.RC1\scripts\_Events.groovy] loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
      Warning, target causing name overwriting of name startLogging
      Error executing script RunWar: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
      java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
      at java.lang.Class.getDeclaredMethods(Class.java:1791)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:33)
      at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:20)
      at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy:106)
      at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy)
      at grails.util.PluginBuildSettings$getPluginInfos.callCurrent(Unknown Source)
      at grails.util.PluginBuildSettings.getPluginInfoForName(PluginBuildSettings.groovy:151)
      at grails.util.PluginBuildSettings$getPluginInfoForName.callCurrent(Unknown Source)
      at grails.util.PluginBuildSettings.getPluginDirForName(PluginBuildSettings.groovy:516)
      at grails.util.PluginBuildSettings$getPluginDirForName.call(Unknown Source)
      at _PluginDependencies_groovy$_run_closure15.doCall(_PluginDependencies_groovy:816)
      at _PluginDependencies_groovy$_run_closure15.call(_PluginDependencies_groovy)
      at _PluginDependencies_groovy$_run_closure4.doCall(_PluginDependencies_groovy:318)
      at _PackagePlugins_groovy$_run_closure2.doCall(_PackagePlugins_groovy:69)
      at _GrailsPackage_groovy$_run_closure2.doCall(_GrailsPackage_groovy:76)
      at _GrailsWar_groovy$_run_closure5.doCall(_GrailsWar_groovy:87)
      at RunWar$_run_closure1.doCall(RunWar.groovy:42)
      at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
      at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
      at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
      at gant.Gant.withBuildListeners(Gant.groovy:344)
      at gant.Gant.this$2$withBuildListeners(Gant.groovy)
      at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
      at gant.Gant.dispatch(Gant.groovy:334)
      at gant.Gant.this$2$dispatch(Gant.groovy)
      at gant.Gant.invokeMethod(Gant.groovy)
      at gant.Gant.processTargets(Gant.groovy:495)
      at gant.Gant.processTargets(Gant.groovy:480)
      Error executing script RunWar: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"

        Issue Links

          Activity

          Bartosz Jablonski created issue -
          Hide
          Nicolas Martignole added a comment -

          I reproduced the same exception with Grails 1.2-M4 on Mac OS X with the Drools plugin version 0.3

          user@host> grails create-app test
          user@host> cd test
          user@host> grails install-plugin drools
          ...
          ...
          Executing drools-0.3 plugin post-install script ...
          Plugin drools-0.3 installed

          user@host> grails run-app
          ...
          ...
          java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
          at java.lang.Class.getDeclaredMethods0(Native Method)
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
          at java.lang.Class.getDeclaredMethods(Class.java:1791)
          at java.security.AccessController.doPrivileged(Native Method)
          at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:33)
          at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:20)
          at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy:95)
          at grails.util.PluginBuildSettings$getPluginInfos.call(Unknown Source)
          at _PackagePlugins_groovy$_run_closure2.doCall(_PackagePlugins_groovy:70)
          at _GrailsPackage_groovy$_run_closure2.doCall(_GrailsPackage_groovy:76)
          at RunApp$_run_closure1.doCall(RunApp.groovy:28)
          at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
          at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
          at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
          at gant.Gant.withBuildListeners(Gant.groovy:344)
          at gant.Gant.this$2$withBuildListeners(Gant.groovy)
          at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
          at gant.Gant.dispatch(Gant.groovy:334)
          at gant.Gant.this$2$dispatch(Gant.groovy)
          at gant.Gant.invokeMethod(Gant.groovy)
          at gant.Gant.processTargets(Gant.groovy:495)
          at gant.Gant.processTargets(Gant.groovy:480)
          Error executing script RunApp: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"

          Show
          Nicolas Martignole added a comment - I reproduced the same exception with Grails 1.2-M4 on Mac OS X with the Drools plugin version 0.3 user@host> grails create-app test user@host> cd test user@host> grails install-plugin drools ... ... Executing drools-0.3 plugin post-install script ... Plugin drools-0.3 installed user@host> grails run-app ... ... java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException" at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) at java.lang.Class.getDeclaredMethods(Class.java:1791) at java.security.AccessController.doPrivileged(Native Method) at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:33) at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:20) at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy:95) at grails.util.PluginBuildSettings$getPluginInfos.call(Unknown Source) at _PackagePlugins_groovy$_run_closure2.doCall(_PackagePlugins_groovy:70) at _GrailsPackage_groovy$_run_closure2.doCall(_GrailsPackage_groovy:76) at RunApp$_run_closure1.doCall(RunApp.groovy:28) at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) Error executing script RunApp: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
          Show
          Graeme Rocher added a comment - does this help? http://old.nabble.com/xerces-2.9.1-%2B-grails-td25085644.html
          Show
          Graeme Rocher added a comment - Or maybe this one: http://old.nabble.com/first-grails-app---Linkage-errors,-java-6-td21882311.html
          Hide
          Nicolas Martignole added a comment -

          Hi Graeme

          Issue has been solved :

          I installed jarscan (https://jarscan.dev.java.net/servlets/ProjectDocumentList) and found that there's a version of xml-apis that is bundled with Grails Drools plugin

          nic@host> cd $HOME/.grails
          nic@host> java -jar /Users/nicolas/Downloads/jarscan/jarscan.jar SAXParseException
          .....................................................................
          +1.2-M4/projects/test/plugins/drools-0.3/lib/xml-apis-1.0.b2.jar
          1.2-M4/projects/test/plugins/drools-0.3/lib/xml-apis-1.0.b2.jar/org/xml/sax/SAXParseException.class
          ----------------------------------------------
          Scanned archives: 70
          Errors: 0

          I deleted xml-apis-1.0.b2 from the plugin lib folder and now it works.

          I'll inform the Drools plugin author, thanks Graeme

          FYI

          1. Grails version: 1.2-M4
          2. JVM version: 1.6.0_15
          Show
          Nicolas Martignole added a comment - Hi Graeme Issue has been solved : I installed jarscan ( https://jarscan.dev.java.net/servlets/ProjectDocumentList ) and found that there's a version of xml-apis that is bundled with Grails Drools plugin nic@host> cd $HOME/.grails nic@host> java -jar /Users/nicolas/Downloads/jarscan/jarscan.jar SAXParseException ..................................................................... +1.2-M4/projects/test/plugins/drools-0.3/lib/xml-apis-1.0.b2.jar 1.2-M4/projects/test/plugins/drools-0.3/lib/xml-apis-1.0.b2.jar/org/xml/sax/SAXParseException.class ---------------------------------------------- Scanned archives: 70 Errors: 0 I deleted xml-apis-1.0.b2 from the plugin lib folder and now it works. I'll inform the Drools plugin author, thanks Graeme FYI Grails version: 1.2-M4 JVM version: 1.6.0_15
          Hide
          Bartosz Jablonski added a comment - - edited

          Hi, I did some investigation and it seems that it is similar problem to http://jira.codehaus.org/browse/GROOVY-2303 .
          I removed xml-apis dependency for xalan and xerces from my pom definition and it's seams that it help.

          I have to remove other dependency now...

          I think it will become a big problem eventually... If you have any idea how to solve it or you can solve it in more general way that would be great.

          Show
          Bartosz Jablonski added a comment - - edited Hi, I did some investigation and it seems that it is similar problem to http://jira.codehaus.org/browse/GROOVY-2303 . I removed xml-apis dependency for xalan and xerces from my pom definition and it's seams that it help. I have to remove other dependency now... I think it will become a big problem eventually... If you have any idea how to solve it or you can solve it in more general way that would be great.
          Hide
          Harlan added a comment -

          I am also experiencing this problem. It seems related to the closed issue http://jira.codehaus.org/browse/GRAILS-5337.

          I have not seen the problem under Maven, only with Ivy. At this point I have been unable to prevent Ivy from loading xml-api, and my only solution has been to place an empty xml-api.jar in the ivy repository.

          I would really appreciate an update on this issue. Thanks,

          – Harlan

          Show
          Harlan added a comment - I am also experiencing this problem. It seems related to the closed issue http://jira.codehaus.org/browse/GRAILS-5337 . I have not seen the problem under Maven, only with Ivy. At this point I have been unable to prevent Ivy from loading xml-api, and my only solution has been to place an empty xml-api.jar in the ivy repository. I would really appreciate an update on this issue. Thanks, – Harlan
          Hide
          Brian Schmoll added a comment -

          I had this issue when resolving some axis2/rampart dependencies in order to consume webservices. Xerces and xml-apis were subdependencies of the axis2/rampart jars in the maven repository. My current solution to prevent xerces and xml-apis is to use the Grails Ivy excludes command.

          build ("axis2/rampart dependencies")

          { excludes "xercesImpl", "xmlParserAPIs", "xml-apis"; }
          Show
          Brian Schmoll added a comment - I had this issue when resolving some axis2/rampart dependencies in order to consume webservices. Xerces and xml-apis were subdependencies of the axis2/rampart jars in the maven repository. My current solution to prevent xerces and xml-apis is to use the Grails Ivy excludes command. build ("axis2/rampart dependencies") { excludes "xercesImpl", "xmlParserAPIs", "xml-apis"; }
          Hide
          Harlan added a comment -

          Thanks Brian, that did the job as a work around. I had tried something similar earlier but had the wrong Ivy syntax (not so familiar with it), so thanks for the example.

          The issues remain rather inconvenient though. When using a Maven pom for dependency management (pom=true in grails config) and running Maven operations everything works, but running a Grails command with the same configuration results in an error. So the work around comes down to maintaining the pom for dependencies (so I can use Maven as part of our standard build) and maintaining the ivy dependency management (so Intellij with work and a developer has the option of running standard Grails commands).

          Show
          Harlan added a comment - Thanks Brian, that did the job as a work around. I had tried something similar earlier but had the wrong Ivy syntax (not so familiar with it), so thanks for the example. The issues remain rather inconvenient though. When using a Maven pom for dependency management (pom=true in grails config) and running Maven operations everything works, but running a Grails command with the same configuration results in an error. So the work around comes down to maintaining the pom for dependencies (so I can use Maven as part of our standard build) and maintaining the ivy dependency management (so Intellij with work and a developer has the option of running standard Grails commands).
          Hide
          Anton Novopashin added a comment -

          I have this issue in grail 1.2.0 version.

          Show
          Anton Novopashin added a comment - I have this issue in grail 1.2.0 version.
          Hide
          Bryan Hughes added a comment -

          I have this issue in 1.3.0RC1 with the GWT plugin.

          Show
          Bryan Hughes added a comment - I have this issue in 1.3.0RC1 with the GWT plugin.
          Graeme Rocher made changes -
          Field Original Value New Value
          Assignee Graeme Rocher [ graemerocher ]
          Hide
          Marcin Floryan added a comment -

          Similar problem occurs when using org.codehaus.groovy.modules.http-builder (http://groovy.codehaus.org/modules/http-builder/home.html)

          The following fixed the problem:
          test('org.codehaus.groovy.modules.http-builder:http-builder:0.5.1')

          { excludes 'xml-apis', 'xercesImpl' }
          Show
          Marcin Floryan added a comment - Similar problem occurs when using org.codehaus.groovy.modules.http-builder ( http://groovy.codehaus.org/modules/http-builder/home.html ) The following fixed the problem: test('org.codehaus.groovy.modules.http-builder:http-builder:0.5.1') { excludes 'xml-apis', 'xercesImpl' }
          Hide
          Jeff Ichnowski added a comment -

          I encountered a similar problem and after following a note on GRAILS-5337, was able to resolve it by deleting my Ivy cache (~/.ivy2/cache). Hope that helps.

          Show
          Jeff Ichnowski added a comment - I encountered a similar problem and after following a note on GRAILS-5337 , was able to resolve it by deleting my Ivy cache (~/.ivy2/cache). Hope that helps.
          Contegix Support made changes -
          Project Import Thu Mar 24 21:22:24 CDT 2011 [ 1301019744151 ]
          Graeme Rocher made changes -
          Key GRAILS-5500 MAVEN-22
          Affects Version/s 1.2-RC1 [ 11021 ]
          Component/s Plugins [ 10426 ]
          Project Grails [ 10020 ] Grails Maven Plugin [ 10284 ]
          Hide
          Ganesh Krishnan added a comment -

          Delete the .ivy2/cache!

          Show
          Ganesh Krishnan added a comment - Delete the .ivy2/cache!
          Hide
          Tom Crossland added a comment - - edited

          Experiencing this problem when performing run-app on a Grails 1.3.7 app with Apache POI 3.8. Excluding xmlbeans from the dependencies seemed to work:

          dependencies {
          compile('org.apache.poi:poi-ooxml:3.8-beta3')

          { excludes "xmlbeans" }

          }

          Show
          Tom Crossland added a comment - - edited Experiencing this problem when performing run-app on a Grails 1.3.7 app with Apache POI 3.8. Excluding xmlbeans from the dependencies seemed to work: dependencies { compile('org.apache.poi:poi-ooxml:3.8-beta3') { excludes "xmlbeans" } }
          Hide
          siddhptl added a comment -

          HI Bryan,
          How did you solve this problem. I am having the same issue and I am not able to solve it. Please help

          Show
          siddhptl added a comment - HI Bryan, How did you solve this problem. I am having the same issue and I am not able to solve it. Please help
          Hide
          Sudheer Prem added a comment - - edited

          I excluded xml-apis in my pom.xml and now the war file is getting created successfully.
          But i'm getting java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal during the runtime.
          If i include xml-api.jar inside the WEB-INF/lib directory after the creation of war file, the error disappeared.
          Unfortunately, i can't do this manually. I'm using Grails 1.3.7.
          (Even including xml-apis with "runtime" dependency in pom.xml doesn't help )
          Any work around for this is highly appreciated.

          Show
          Sudheer Prem added a comment - - edited I excluded xml-apis in my pom.xml and now the war file is getting created successfully. But i'm getting java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal during the runtime. If i include xml-api.jar inside the WEB-INF/lib directory after the creation of war file, the error disappeared. Unfortunately, i can't do this manually. I'm using Grails 1.3.7. (Even including xml-apis with "runtime" dependency in pom.xml doesn't help ) Any work around for this is highly appreciated.
          Graeme Rocher made changes -
          Project Grails Maven Plugin [ 10284 ] Grails [ 10020 ]
          Key MAVEN-22 GRAILS-8819
          Workflow jira [ 35569 ] Grails2 [ 103753 ]
          Last Reviewed 23/Feb/12
          Hide
          Graeme Rocher added a comment -

          Although this still "could" happen in Grails 2 we have reduced the risk greatly by automatically excluding xml-apis and any XML jars from dependency resolution, hence reducing the priority

          Show
          Graeme Rocher added a comment - Although this still "could" happen in Grails 2 we have reduced the risk greatly by automatically excluding xml-apis and any XML jars from dependency resolution, hence reducing the priority
          Graeme Rocher made changes -
          Priority Major [ 3 ] Minor [ 4 ]
          Hide
          mike added a comment -

          Just a note on one jar you might want to add to the exclusions, xom
          That one was causing the same issues that this one was so just thought i'd mention it.

          Show
          mike added a comment - Just a note on one jar you might want to add to the exclusions, xom That one was causing the same issues that this one was so just thought i'd mention it.
          Hide
          Chris Cooper added a comment -

          This still affects me, and when using exclusions I get runtime errors.

          I am using grails 2.1

          Show
          Chris Cooper added a comment - This still affects me, and when using exclusions I get runtime errors. I am using grails 2.1
          Hide
          Jon Oler added a comment -

          I believe that much of what is reported here is due to GRAILS-9352.

          Show
          Jon Oler added a comment - I believe that much of what is reported here is due to GRAILS-9352 .
          Graeme Rocher made changes -
          Link This issue duplicates GRAILS-9352 [ GRAILS-9352 ]
          Graeme Rocher made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Assignee Graeme Rocher [ graemerocher ]
          Fix Version/s 2.1.1 [ 13207 ]
          Fix Version/s 2.2 [ 13093 ]
          Resolution Fixed [ 1 ]

            People

            • Assignee:
              Graeme Rocher
              Reporter:
              Bartosz Jablonski
            • Votes:
              13 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Last Reviewed:

                Development