【问题标题】:Spring Boot Property Launcher + EhCache Failed to read schema documentSpring Boot Property Launcher + EhCache 无法读取架构文档
【发布时间】:2020-07-11 16:42:27
【问题描述】:

我正在开发一个 Spring Boot(2.3.0.RELEASE) 项目,该项目需要使用外部加载器来加载一些专有库。因此我们使用 Spring 的 Property Launcher 如下,

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration> 
        <layout>ZIP</layout> 
        <mainClass>com.app.Application</mainClass> 
  </configuration>
</plugin>

我们还使用 Ehcache 版本 3.8.1 以及 Spring 的 CacheAutoConfiguration
我们面临的问题是,由于某种原因,ehcache 模式 xsd 文件对类加载器不可见,并且由于以下异常而失败。
我已经验证 xsd 存在于它失败的确切路径中。

Caused by: org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'jar:file:/C:/workspace/poc/external-loader-poc/target/external-loader-poc.jar!/BOOT-INF/lib/ehcache-3.8.1.jar!/ehcache-core.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source) ~[na:1.8.0_251]
        at javax.xml.validation.SchemaFactory.newSchema(Unknown Source) ~[na:1.8.0_251]
        at javax.xml.validation.SchemaFactory.newSchema(Unknown Source) ~[na:1.8.0_251]
        at org.ehcache.xml.ResourceConfigurationParser.<clinit>(ResourceConfigurationParser.java:67) ~[ehcache-3.8.1.jar!/:na]
        ... 58 common frames omitted
Caused by: java.io.FileNotFoundException: JAR entry BOOT-INF/lib/ehcache-3.8.1.jar!/ehcache-core.xsd not found in C:\workspace\poc\external-loader-poc\target\external-loader-poc.jar
        at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source) ~[na:1.8.0_251]
        at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source) ~[na:1.8.0_251]
        at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source) ~[na:1.8.0_251]

但是,使用JarLauncherWarLauncher 时不会发生此问题。它只发生在PropertyLauncher 上。 任何建议都会有很大帮助。

【问题讨论】:

    标签: spring-boot spring-boot-maven-plugin ehcache-3


    【解决方案1】:

    我有同样的问题。我正在使用带有 ehcache 3 的 SpringBoot 2.3.0.RELEASE。刚刚升级到 Spring Boot 2.3.2.RELEASE。问题解决了。如果可能,请尝试升级 SpringBoot。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-01
      • 2019-08-19
      • 2014-07-11
      • 1970-01-01
      • 2014-12-04
      • 2015-06-10
      相关资源
      最近更新 更多