Xi: include in xml file in jar file does not work in WildFly

Here's the script:

I linked several .xml (several configurations) needed to run my application in a .jar file. The jar file has the following structure:

 settings-1.0.0.jar หช resources/ หช 1.xml หช 2.xml หช 3.xml หช META-INF/ หช MANIFEST.MF 

1.xml has the following contents:

 <?xml version="1.0" encoding="UTF-8"?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <!-- Include 2 --> <xi:include href="resource:resources/2.xml" /> <!-- Include 3 --> <xi:include href="resource:resources/3.xml" /> <!-- <map> </map> --> </document> 

based on this article . When I try to access them (after successfully deploying my application), I get the following error:

 Caused by: org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 43; An 'include' failed, and no 'fallback' element was found. at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:245) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:298) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) at org.zcore.dkp.backend.mapper.MappingParser.parse(MappingParser.java:60) ... 327 more 

I tried (& error'd) all imaginable options. What is the correct combination for xi:include 'of the .xml file in the jar file installed as the WildFly module?

Edit: this is how the xml file loads:

 private void loadBackendMapping() { try { BackendMappingParser parser = new BackendMappingParser(); InputStream in = ResourceLoaderHelper.getResourceAsStream(BACKEND_MAPPING_RESOURCE); if (in == null) { throw new FileNotFoundException(); } try { parser.parse(in); } finally { try { in.close(); } catch (IOException e) { log.warn("Failed to close " + BACKEND_MAPPING_RESOURCE, e); } } backendMapping = parser.getMapping(); if (log.isDebugEnabled()) { log.debug(BACKEND_MAPPING_RESOURCE + " successfully loaded!"); } } catch (FileNotFoundException e) { log.warn("\"" + BACKEND_MAPPING_RESOURCE + "\" not found!"); backendMapping = new BackendMapping(); } catch (Exception e) { throw new CenterwareSystemException("Failed to parse " + BACKEND_MAPPING_RESOURCE, e); } } 

BACKEND_MAPPING_RESOURCE contains the file name ( 1.xml ).

+7
java xml module wildfly xerces
source share
2 answers

It depends on your XML parsing.

By your exception, it seems that you are using SAX.
Try this article: https://www.ibm.com/developerworks/library/x-tipentres/

The above document uses the SAX API EntityResolver to search for resources in an XML document.

+2
source share

Remove the "resource:" prefix from your URLs, as this is apparently a specific JBoss protocol.

We also emit the path "resource /", since 1.xml, 2.xml and 3.xml are all in the same folder, and you usually specify the relative path (from 1 to 2 and from 1 to 3).

Try the following:

 <?xml version="1.0" encoding="UTF-8"?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <!-- Include 2 --> <xi:include href="2.xml" /> <!-- Include 3 --> <xi:include href="3.xml" /> <!-- <map> </map> --> </document> 
+1
source share

All Articles