(Edited: look at the end for the shortest direct statement of the problem)
I'm trying to run msv-generator from https://github.com/xmlark/msv.
I downloaded this source, built it and put the following jars in a folder (skipped javadocs, sources, tests
):
ant.jar
crimson.jar
isorelax.jar
jdom.jar
junit.jar
maven-repository-importer.jar
msv-core-2017.2-SNAPSHOT.jar
msv-generator-2017.2-SNAPSHOT.jar
msv-rngconverter-2017.2-SNAPSHOT.jar
original-msv-rngconverter-2017.2-SNAPSHOT.jar
relaxngDatatype.jar
resolver.jar
saxon.jar
servlet.jar
xalan.jar
xercesImpl.jar
xmlParserAPIs.jar
xsdlib-2017.2-SNAPSHOT.jar
When I try to run it I get this error
java -cp "c:/prog/msv/*" com.sun.msv.generator.Driver schema.rng
parsing a grammar: schema.rng
generating document #1
Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
This class is present in the jars:
unzip -l xercesImpl.jar |grep DocumentLS
329 11-11-2002 17:20 org/w3c/dom/ls/DocumentLS.class
But my java seems to look for org.w3c.dom
in a module not in the provided jar:
java -version
java version "13.0.2" 2020-01-14
Java(TM) SE Runtime Environment (build 13.0.2+8)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
java -verbose:class -cp "c:/prog/msv/*" com.sun.msv.generator.Driver schema.rng|grep org.w3c.dom
parsing a grammar: schema.rng
[1.249s][info][class,load] org.w3c.dom.Node source: jrt:/java.xml
generating document #1
[2.470s][info][class,load] org.w3c.dom.Document source: jrt:/java.xml
[2.481s][info][class,load] org.w3c.dom.CharacterData source: jrt:/java.xml
I think it's the jdk.xml.dom
module, but it doesn't provide org.w3c.dom.ls
:
java --describe-module jdk.xml.dom
jdk.xml.dom@13.0.2
exports org.w3c.dom.css
exports org.w3c.dom.html
exports org.w3c.dom.stylesheets
exports org.w3c.dom.xpath
requires java.base mandated
requires java.xml transitive
Adding the module explicitly makes no difference:
java --add-modules jdk.xml.dom -cp "c:/prog/msv/*" com.sun.msv.generator.Driver schema.rng
parsing a grammar: schema.rng
generating document #1
Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
https://stackoverflow.com/a/5756989/285364 describes the difference between java.lang.ClassNotFoundException
and java.lang.NoClassDefFoundError
. I'm getting the latter, and it may mean there's an error in the class initializer. So I tried to load it directly:
java -cp c:/prog/msv/xercesImpl.jar org.w3c.dom.ls.DocumentLS
Error: Could not find or load main class org.w3c.dom.ls.DocumentLS
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ls.DocumentLS
Now I'm stumped because that class is in that jar:
unzip -l c:/prog/msv/xercesImpl.jar |grep DocumentLS
329 11-11-2002 17:20 org/w3c/dom/ls/DocumentLS.class
What could be wrong with that class? I decomplied it with jad and it looks ok... Except it's not a class but an interface?
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
package org.w3c.dom.ls;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
public interface DocumentLS
{
public abstract boolean getAsync();
public abstract void setAsync(boolean flag)
throws DOMException;
public abstract void abort();
public abstract boolean load(String s);
public abstract boolean loadXML(String s);
public abstract String saveXML(Node node)
throws DOMException;
}