简体   繁体   中英

Application fails to find XSD file using One-Jar

I am using One-Jar's maven plugin to package my java into one jar with all it's dependencies.

The project has a resource called schema.xsd.

when I run the jar file using java -jar myJar.one-jar I get the following error:

 org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document
 'jar:file:/../lib/myJar.one-jar.jar!/lib/myJar.jar!/schema.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>.

Any idea why this is happening?

Note: the application has a log4j.properties as a resource and it recognizes it.

i'm pretty sure the Jar url connection handling implementation in the jre cannot handle more than one level of nesting (that url has 2 '!' characters in it). not sure how one-jar handles reading the class files out of the nested jars, but you may need to extract the xsd to a temp file before you can use it.

personally, i generally use the maven assembly plugin with the "jar-with-dependencies" goal, which works just fine unless you have conflicting files in one or your jars.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM