我面临一个奇怪的问题。我正在尝试创建XML模式以验证文件。我在我的函数中执行以下操作:
String schemaFilename = ApplicationConfiguration.xsdConfiguration.getTypeMappings().get(fileType);
ClassLoader classLoader = getClass().getClassLoader();
File schemaFile = new File(classLoader.getResource(ApplicationConfiguration.xsdConfiguration.getXsdSchemasLocation()+schemaFilename).getFile());
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = null;
try
{
schema = schemaFactory.newSchema(schemaFile);
}
catch (SAXException e) {
logger.error("Could not instantiate XSD schema from file: {}", schemaFile.getName());
e.printStackTrace();
validXML = false;
}
当我通过Intellij或Maven在Windows上运行测试时,一切正常。当我试图在Jenkins上构建时,在Centos上运行我得到SAXExceptions(编辑堆栈跟踪)
org.xml.sax.SAXParseException; systemId: file:/...myfile.xsd; lineNumber: 48; columnNumber: 39; src-resolve: Cannot resolve the name 'AnElement' to a(n) 'type definition' component.
关于可能出错的任何想法?