我正在针对已知架构验证xml并获得stackoverflow错误。我的xml出了什么问题?我应该寻找什么?从1.6 Java中找到的代码抛出了这个错误。
JAXBContext context = JAXBContext.newInstance(Root.class);
Unmarshaller un = context.createUnmarshaller();
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL resource = ClassLoader.getSystemResource("schema.xsd");
if (resource == null) {
throw new IllegalStateException("Could not find schema!");
}
Schema schema = schemaFactory.newSchema(resource);
un.setSchema(schema);
Root root = un.unmarshal(xml) // Error thrown here
错误:
java.lang.StackOverflowError
at com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression.matchString(RegularExpression.java:1878)
at com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression.matchString(RegularExpression.java:1878)