|
FWIW I stumbled upon this bug recently while using jedit 4.2 and Griffon 0.1-SNAPSHOT (based on groovy 1.6-rc1). ------------------------------------------------------------ Press TAB with an empty command line to list built-in commands. Errors generated by compilers and some other programs are listed Base Directory: /tmp/Simple Base Directory: /tmp/Simple there is of course a obvious workaround when using the groovy command and that is to put these jars in the bootloader instead of the RootLoader. So it should not go into $GROOVY_HOME/lib, but given as command line argument to the -cp option for the groovy command. I tried your suggested workaround, specifying "-cp xmlparserv2-10.1.0.2.0.jar". It gave me the same error. (Using 1.6 RC-3.) Maybe I don't understand how to apply this workaround. I think "-cp" is placing the class into the RootLoader, not the BootLoader. I can report the class loader for NamedNodeMap with a script thus: def printClassLoader(Class cls) { When I run this without options, I get no output. I believe this is because on my system the boot loader is returned as null from Class#getClassLoader(). When I run this script with "-cp xmlparserv2-10.1.0.2.0.jar", it outputs (among other things): interface org.w3c.dom.NamedNodeMap This indicates to me that the class is now in the RootLoader. This won't fix the problem, right? John Hurst When I said "the class is now in the RootLoader", I should have been more clear. The version I want is in the RootLoader, but the SDK version is still in the BootLoader. Thus the 1.5.7 patch loads the boot loader version. John Hurst true, I forgot, that that won't work. Now it is more clear to me why we did came up with that hack. Because in the issue I mentioned you could put the jaxen.jar in the bootloader and it would behave well, but that won't be easy using the groovy command alone. And for here it is really the opposite of what we want. What I don't get atm is how that jar is normally used. For jaxen I know if it is in the same loader as the xml parser there is no problem. And if the loader is a normal one, then it is the same. Now for xmlparserv I am not allowed to use the parent loader because... well why? I guess because there are other classes that duplicate xml parser classes as well. Is there no xmlparserv2 without that part? First off: Thanks very much for putting time into this issue. I feel like I ought to be paying you guys. You rock. My understanding with the Oracle XML classes is that Oracle ships a back-level implementation of the Java DOM APIs. Thus, the interfaces are older versions than those in the current JDK, and the implementations do not necessarily implement all the required signatures in the current JDK. Thus the incompatibility. The Oracle JAR includes classes/interfaces from The javax and org.w3c classes/interfaces mirror JDK classes/interfaces, but are different versions. For example, from JDK 1.6.0_10: 432 Fri Sep 26 01:22:26 NZST 2008 org/w3c/dom/Attr.class From xmlparserv2,jar: 387 Mon Nov 10 15:17:46 NZDT 2003 org/w3c/dom/Attr.class The oracle.xml classes are, of course, the Oracle implementations. If I try to run my application, using Oracle XML dev kit, without the Oracle XML classes, I get This class is in xmlparserv2.jar. I could try to create a JAR with just the Oracle implementation classes, and not the interfaces. I suspect it would not work, because the implementations would not be compatible with the JDK interfaces. Obviously, a good solution for this would be if Oracle updated their package to include the latest DOM APIs! The latest version of Oracle XML Developer's kit I can find is 10.2.0.2.0, dated 2006-03-31, and this has DOM API versions similar to the one I've been using. Thanks for your suggestions. John Hurst I tried removing the standard javax.xml/dom/sax/ interfaces and classes from Oracle's xmlparserv2.jar. Hey, it worked! This is good enough for me. (I thought that the class load/validation was stricter than it is.) If anyone wants to do the same, here is an Ant step to create your new JAR: <!-- Create xmlparserv2-local: with SDK classes/interfaces omitted, works better with Groovy 1.5.7+. --> I found that I needed to include org.w3c.dom.validation.*; those aren't present in my JDK. Thanks! John Hurst I have a similar problem with html-unit-2.4. Being new to java and groovy, I really have no idea what this means. I'm getting this message: Caught: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/NamedNodeMap" from this program: import com.gargoylesoftware.htmlunit.WebClient; def webClient = new WebClient() The HtmlUnit 2.4 download package includes a bunch of JARs, including xml-apis-1.3.04.jar. This JAR includes the NamedNodeMap class, in a different version from JDK 1.6.0. I tried your program after removing this JAR from the classpath, and that fixes it. (Move it out of the directory if your app is including all JARs in a directory in the classpath. E.g. you may have put the JAR in ~/.groovy/lib/.) John Hurst Thanks John! I wasn't expecting such a timely response. That change you mentioned did get me past the problem. Got warning message Feb 20, 2009 8:39:48 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl But, I think the script did what it was supposed to do. I've had a hard time finding examples for htmlunit. There seems to be a lot more for httpunit, which I presume is a predecessor. If anyone could point me in the right direction, I'd be much obliged. For what it's worth I'm using the work around described here: http://www.jroller.com/hasant/entry/how_to_change_oracle_xml The difference is that I'm substituting the META-INF/services from the newer xerces and xalan and not the classes specified in the article. This works fine for me and I can use the XDB XMLType in my code. The other applications on the server seem perfectly fine with this substitution. Caught: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/NamedNodeMap" I'm having this problem with groovy and htmlunit-2.6. In the past, I've simply deleted the xml-apis-1.3.04.jar file from the groovy lib directory, but this isn't working anymore. java version "1.6.0_17" @zuzum2: You may need to find out where in your classpath you have org/w3c/dom/NamedNodeMap, and thus look for clashes. Also, have you tried a more recent Groovy? John Hurst |
||||||||||||||||||||||||||||||||||||||||||
this XML parser stuff is really a PITA. I added that hack to avoid problems with class loading and in your case it is causing exactly that. You can find the discussion from back in http://markmail.org/message/hn3tv6s2jeyjslcb#query:org.w3c.dom.Node%20rootloader+page:1+mid:5nw3tlvar5pmcmc4+state:results
related issues are
GROOVY-2303andGANT-34