gpt4 book ai didi

maven-2 - Raml 验证器在 javax.xml.validation.SchemaFactory.newSchema 中引发错误

转载 作者:行者123 更新时间:2023-12-02 20:42:23 24 4
gpt4 key购买 nike

尝试验证 espn.raml 时我收到以下错误。相同的代码对于 gmail.raml 工作正常。为什么会发生这种情况?为了供您引用,我已经包含了我发现 SchemaFactory 包含的 jar 的结果。

$ 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");

它不会抛出异常并返回一个空 List<ValidationResult> ,因为此 RAML 文件是有效的。

我的环境:

Apache Maven 3.3.3
Java version: 1.8.0_60, vendor: Oracle Corporation

就我而言,javax.xml.validation.SchemaFactory由JDK本身提供。您应该努力做到这一点,即确保没有其他库可以将此类贡献给您的代码,或者通过使用不包含此类的备用 JAR(这些似乎是 WSO2 特定版本,其他版本可能不同?)或者如果执行环境允许的话,可以使用类加载器过滤。

编辑 正如评论中所添加的,修复方法是排除 xml-apis:xml-apis来自 RAML 解析器。这种排除是有道理的,因为最近的 JDK 提供了 RAML 解析器所需的内容。

关于maven-2 - Raml 验证器在 javax.xml.validation.SchemaFactory.newSchema 中引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32570593/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com