Raml 验证器在 javax.xml.validation.SchemaFactory.newSchema 中抛出错误
Raml validator throws an error in javax.xml.validation.SchemaFactory.newSchema
尝试验证时 espn.raml I got the below error. Same code is working fine for gmail.raml。为什么会这样?
为了您的参考,我已经包含了我发现 SchemaFactory 包含的 jars 的结果。
$ find *.jar | xargs grep SchemaFactory.class Binary file
axiom_1.2.11.wso2v6.jar matches Binary file
org.apache.openjpa_2.2.0.wso2v1.jar matches Binary file
solr_5.2.1.wso2v1.jar matches
这是我遇到的异常:
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.validation.SchemaFactory.newSchema(Ljavax/xml/transform/Source;)Ljavax/xml/validation/Schema;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/raml/parser/rule/SchemaRule, and the class loader (instance of <bootloader>) for resolved class, javax/xml/validation/SchemaFactory, have different Class objects for the type m/Source;)Ljavax/xml/validation/Schema; used in the signature
at org.raml.parser.rule.SchemaRule.doValidateValue(SchemaRule.java:118)
at org.raml.parser.rule.SchemaRule.doValidateValue(SchemaRule.java:48)
at org.raml.parser.rule.DefaultTupleRule.validateValue(DefaultTupleRule.java:108)
at org.raml.parser.visitor.YamlDocumentValidator.onScalar(YamlDocumentValidator.java:115)
at org.raml.parser.visitor.NodeVisitor.visitScalar(NodeVisitor.java:256)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:222)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitDocument(NodeVisitor.java:209)
at org.raml.parser.visitor.YamlValidationService.validate(YamlValidationService.java:65)
at org.raml.parser.visitor.YamlValidationService.validate(YamlValidationService.java:95)
at org.raml.parser.visitor.YamlValidationService.validate(YamlValidationService.java:82)
at org.raml.parser.visitor.YamlValidationService.validate(YamlValidationService.java:72)
at org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor.isValidateRAML(RAMLProcessor.java:127)
at org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor.processRAML(RAMLProcessor.java:79)
at org.wso2.carbon.registry.custom.extensions.handlers.RAMLMediaTypeHandler.put(RAMLMediaTypeHandler.java:157)
at org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager.put(HandlerManager.java:2503)
... 78 more
这很奇怪。我没问题运行以下:
RamlValidationService
.createDefault()
.validate("http://api.apihub.com/onpositive/api/espn-raml-api/espn.raml");
它没有抛出异常并且 returns 一个空的 List<ValidationResult>
,因为这个 RAML 文件是有效的。
我的环境:
Apache Maven 3.3.3
Java version: 1.8.0_60, vendor: Oracle Corporation
在我的例子中,javax.xml.validation.SchemaFactory
是由 JDK 本身提供的。您应该努力做到这一点,即确保没有其他库可以通过使用不包含此 class 的备用 JAR(这些似乎是 WSO2 特定版本)为您的代码贡献此 class ,其他版本可能不同?)或使用 classloader 过滤,如果执行环境允许的话。
EDIT 正如在评论中添加的那样,修复是从 RAML 解析器中排除 xml-apis:xml-apis
。这种排除是有道理的,因为最近 JDKs 提供了 RAML 解析器所需的内容。
从 raml-parser 中排除 xml-apis 完成了这项工作。
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
现在可以正常验证了。
尝试验证时 espn.raml I got the below error. Same code is working fine for gmail.raml。为什么会这样? 为了您的参考,我已经包含了我发现 SchemaFactory 包含的 jars 的结果。
$ find *.jar | xargs grep SchemaFactory.class Binary file
axiom_1.2.11.wso2v6.jar matches Binary file
org.apache.openjpa_2.2.0.wso2v1.jar matches Binary file
solr_5.2.1.wso2v1.jar matches
这是我遇到的异常:
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.validation.SchemaFactory.newSchema(Ljavax/xml/transform/Source;)Ljavax/xml/validation/Schema;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/raml/parser/rule/SchemaRule, and the class loader (instance of <bootloader>) for resolved class, javax/xml/validation/SchemaFactory, have different Class objects for the type m/Source;)Ljavax/xml/validation/Schema; used in the signature
at org.raml.parser.rule.SchemaRule.doValidateValue(SchemaRule.java:118)
at org.raml.parser.rule.SchemaRule.doValidateValue(SchemaRule.java:48)
at org.raml.parser.rule.DefaultTupleRule.validateValue(DefaultTupleRule.java:108)
at org.raml.parser.visitor.YamlDocumentValidator.onScalar(YamlDocumentValidator.java:115)
at org.raml.parser.visitor.NodeVisitor.visitScalar(NodeVisitor.java:256)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:222)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:86)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:218)
at org.raml.parser.visitor.NodeVisitor.visitResolvedNode(NodeVisitor.java:180)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:151)
at org.raml.parser.visitor.NodeVisitor.visitDocument(NodeVisitor.java:209)
at org.raml.parser.visitor.YamlValidationService.validate(YamlValidationService.java:65)
at org.raml.parser.visitor.YamlValidationService.validate(YamlValidationService.java:95)
at org.raml.parser.visitor.YamlValidationService.validate(YamlValidationService.java:82)
at org.raml.parser.visitor.YamlValidationService.validate(YamlValidationService.java:72)
at org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor.isValidateRAML(RAMLProcessor.java:127)
at org.wso2.carbon.registry.custom.extensions.handlers.utils.RAMLProcessor.processRAML(RAMLProcessor.java:79)
at org.wso2.carbon.registry.custom.extensions.handlers.RAMLMediaTypeHandler.put(RAMLMediaTypeHandler.java:157)
at org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager.put(HandlerManager.java:2503)
... 78 more
这很奇怪。我没问题运行以下:
RamlValidationService
.createDefault()
.validate("http://api.apihub.com/onpositive/api/espn-raml-api/espn.raml");
它没有抛出异常并且 returns 一个空的 List<ValidationResult>
,因为这个 RAML 文件是有效的。
我的环境:
Apache Maven 3.3.3
Java version: 1.8.0_60, vendor: Oracle Corporation
在我的例子中,javax.xml.validation.SchemaFactory
是由 JDK 本身提供的。您应该努力做到这一点,即确保没有其他库可以通过使用不包含此 class 的备用 JAR(这些似乎是 WSO2 特定版本)为您的代码贡献此 class ,其他版本可能不同?)或使用 classloader 过滤,如果执行环境允许的话。
EDIT 正如在评论中添加的那样,修复是从 RAML 解析器中排除 xml-apis:xml-apis
。这种排除是有道理的,因为最近 JDKs 提供了 RAML 解析器所需的内容。
从 raml-parser 中排除 xml-apis 完成了这项工作。
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
现在可以正常验证了。