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

          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.
          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
          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 .

            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