This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Groovy and the fly likes loader constraint violation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "loader constraint violation" Watch "loader constraint violation" New topic
Author

loader constraint violation

Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Hello fellow developers. I'm a complete newbie to Groovy and Grails. I'm going through a tutorial here http://www.grails.org/NetBeans+Integration
When I attempt to run the application I see the following error in my console output.

Running Grails application..
2010-09-17 10:19:46,693 [main] ERROR context.GrailsContextLoader - Error executing bootstraps: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/NamedNodeMap"
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/NamedNodeMap"
at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:723)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:573)
at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:519)
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:164)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/NamedNodeMap"
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:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at grails.spring.DynamicElementReader.invokeMethod(DynamicElementReader.groovy:121)
... 26 more


Any help resolving this error would be greatly appreciated.
I'm using Netbeans 6.9.1
Grails 1.3.4
I also installed groovy seperately from Grails. My version of groovy is 1.7.5 and my JVM is 1.6.0_16


Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
For what it's worth I get the same error from the command line. Ideas anyone?
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
I rolled back to Grails 1.1. I used the grails run-app from the command line and got the following error.

Running Grails application..
2010-09-21 10:46:27,302 [main] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginMetaManager' defined in Serv
letContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.Lin
kageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different typ
e with name "org/w3c/dom/Document"
at java.security.AccessController.doPrivileged(Native Method)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy:145)
at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:269)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:137)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:104)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:58)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
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)
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loa
ding for a different type with name "org/w3c/dom/Document"
at com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault.getDTMHandleFromNode(DTMManagerDefault.java:494)
at com.sun.org.apache.xpath.internal.XPathContext.getDTMHandleFromNode(XPathContext.java:182)
at com.sun.org.apache.xpath.internal.XPath.execute(XPath.java:301)

Anyway, it fired up jetty but I get a 503 service unavailable error. Surely there's someone here that's experienced this before.
What should I do?
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
What a pain. Lol, for something that's supposed to be painless I find this issue very ironic. The superlative hype surrounding Grails is nothing short of astounding. I hope this isn't a sign of things to come. I feel violated...lol. Lied to. Anyway, enough complaining. I came across this http://grails.1312388.n4.nabble.com/Linkage-Error-after-upgrading-to-Grails-1-1-RC2-td1369597.html
I did what was suggested and put the xalan, xerces, and xml-apis jars in the lib folder and got the exact same error. I found some newer versions of those jars and the error finally disappeared.

Why, if this has been occuring since Grails 1.1 hasn't this been corrected? Surely, everyone has had a similar issue. At the very least I would think it would be documented somewhere or covered in Grails tutorials.
Kat Light
Greenhorn

Joined: Oct 18, 2010
Posts: 5
Ive been having the same issue and I tried searching everywhere!!

Hope there's someone here who can help us
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Kat Light wrote:Ive been having the same issue and I tried searching everywhere!!

Hope there's someone here who can help us


You're in luck. It's definitely a classpath issue and it's specific to your machine. In my case, the issue was I inherited an axis1 web service from my predecessor. Part of the setup instructions for axis one was setting up an axis classpath on windows. The setup instructions I found required that I put xml-apis.jar and xercesImpl.jar on the windows classpath. So to make a long story short, what was happening is that grails was compiling and needed one of those jars and the operating system handed grails the jar that was defined on the windowsclasspath. Somewhere down the line that was causing some sort of class collision. In short, grails was NOT getting the correct class it needed. I finally figured out that I didn't really need to put xalan, xerces, and xml-apis jars in the lib folder. So I took them out, removed the axis1 classpath from windows and the whole thing worked magically.

It is very likely you are facing something similar. Classpath issues can be a real pain to figure out. In my case, it was approx one year since I had setup Axis1. I had completely forgotten about doing that.

What tipped me off to it not being a grails issue is two things.
1. No one else seemed to have this issue.
2. I installed on another machine and it ran flawlessly.
Kat Light
Greenhorn

Joined: Oct 18, 2010
Posts: 5
Thanks so much, will try this today
Kat Light
Greenhorn

Joined: Oct 18, 2010
Posts: 5
How did you discover that it was the axis jar causing the issue?

Server failed to start: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/management/MBeanServer"

^This was mine

Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Well, it wasn't really the axis jar itself, but the axis classpath. The axis classpath had me put xalan, xerces, and xml-apis jars on the windows class path. Those jars were in conflict with what grails needed. When I came across that link that told me to put those jars in the grails lib directory I knew then that grails wasn't getting the correct version of those jars. When I installed grails on another machine and it ran correctly, then I knew there was something on my windows class path that was causing the issue. I'm still learning grails. I love it so far. All the nightmare wiring I've had to do in the past with maven, spring, ibatis, is largely done for you right out of the box and that's simply amazing. I was hoping to use grails for web services but it doesn't look like it can do wsdl first development which is unfortunate. There may be a plugin that supports that, but I don't know yet. I'm still learning it. It only seems to do restful services and I favor restful "jax-ws style" operations. I'm rambling now. Later!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

For what's it worth, I've been using grails since version 1.1 on Windows, Linux, and OSX and I've never ever run into this problem. Of course, I have ZERO classpaths set in my system. I always set classpaths specifically at the project level (or just let the IDE do it) rather than having them global.


GenRocket - Experts at Building Test Data
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Gregg Bolinger wrote:For what's it worth, I've been using grails since version 1.1 on Windows, Linux, and OSX and I've never ever run into this problem. Of course, I have ZERO classpaths set in my system. I always set classpaths specifically at the project level (or just let the IDE do it) rather than having them global.


Gregg, that's actually a very good point about defining classpaths at the project level. Because of this issue, I've decided that system classpaths are inherently evil.
Kat Light
Greenhorn

Joined: Oct 18, 2010
Posts: 5
Hello, just an update, I removed all the jboss related jars and encountered this warning

Warning - could not install some modules: Java Web Applications - The module named org.netbeans.modules.j2ee.jboss4/1 was needed and not found. 6 further modules could not be installed due to the above problems.

Kat Light
Greenhorn

Joined: Oct 18, 2010
Posts: 5
Yep, still had the
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)Server failed to start: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "javax/management/MBeanServer"

at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)



issue



*FRUSTRATED*
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: loader constraint violation
 
Similar Threads
How to use Servlets using Netbeans 6.7.1 and JBoss 5.1.0 GA
[Grails] Why my test isn't passed successfully?
Isn't Java type-safe?
Tomcat Error
[PDF plugin] Having problems with instalation