I am working on a Spring Boot(2.3.0.RELEASE) project where there is a need to use a external loader to load few proprietary libraries. Hence we are using Spring's Property Launcher as follows,
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<mainClass>com.app.Application</mainClass>
</configuration>
</plugin>
We also use Ehcache version 3.8.1 along with Spring's CacheAutoConfiguration
.
The problem we are facing is, for some reason the ehcache schema xsd file is not visible to the classloader and it is failing with the below exception.
I have verified the xsd is present in the exact path that its failing on.
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]
However this issue doesn't happen when using the JarLauncher
or WarLauncher
. It only happens with the PropertyLauncher
.
Any suggestions would be of great help.