[
https://issues.apache.org/jira/browse/OFBIZ-12437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17457971#comment-17457971
]
ASF subversion and git services commented on OFBIZ-12437:
---------------------------------------------------------
Commit bdf94f31a196836825c38909e6fc2221baf2ca4b in ofbiz-framework's branch
refs/heads/release17.12 from Mathieu Lirzin
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=bdf94f3 ]
Fixed: All local XML schema files are now present in classpath, Backport form
trunk
(OFBIZ-11132) (OFBIZ-12437)
Previously there was some warnings about missing “.xsd” files that
‘UtilXml#resolveEntity’ failed to find in classpath. This has been
fixed by declaring all “dtd” directories inside components as resources.
git-svn-id:
https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862346
13f79535-47bb-0310-9956-ffa450edef68
> Resolve local xsd on UtilXml class
> ----------------------------------
>
> Key: OFBIZ-12437
> URL: https://issues.apache.org/jira/browse/OFBIZ-12437
> Project: OFBiz
> Issue Type: Bug
> Components: framework/base
> Affects Versions: 17.12.08, 18.12.02
> Reporter: Nicolas Malin
> Assignee: Nicolas Malin
> Priority: Major
> Labels: start, xsd
>
> Since we migrate OFBiz to gradle, some xsd are resolved during the xml
> validation process directly on internet.
> But in the code base, by default we tried to resolve it before on the local
> code base and only if nothing is found we call on external.
> On UtilXml.java:423 :
> {code:java}
> public static Document readXmlDocument(InputStream is, boolean validate,
> String docDescription)[...]
> /* Standard JAXP (mostly), but doesn't seem to be doing XML Schema
> validation, so making sure that is on... */
> DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> factory.setValidating(validate);
> [...]
> DocumentBuilder builder = factory.newDocumentBuilder();
> if (validate) {
> LocalResolver lr = new LocalResolver(new DefaultHandler());
> ErrorHandler eh = new LocalErrorHandler(docDescription, lr);
> builder.setEntityResolver(lr);
> builder.setErrorHandler(eh);
> }
> document = builder.parse(is);{code}
> The validating function call a local resolver that try to resolve through
> UtilURL.java the xsd file extrat form the schema location, with :
> {code:java}
> schemaLocation="http://ofbiz.apache.org/Widget-Theme
> http://ofbiz.apache.org/dtds/widget-theme.xsd"{code}
> ofbiz try to resolve :
> {code:java}
> widget-theme.xsd{code}
> However, this resolution failed, the code present on UtilURL.java:82
> {code:java}
> public static URL fromResource(String resourceName, ClassLoader loader) {
> URL url = urlMap.get(resourceName);
> if (url != null) {
> try {
> return new URL(url.toString());
> } catch (MalformedURLException e) {
> Debug.logWarning(e, "Exception thrown while copying URL: ",
> module);
> }
> } [...]{code}
> Execute different scan through the classLoader.
> If we check what is loaded on the ofbiz start with gradle we can see that
> only one xsd directory is present :
> {code:java}
> resources {
> srcDirs = getDirectoryInActiveComponentsIfExists('src/main/java')
> srcDirs += getDirectoryInActiveComponentsIfExists('config')
> srcDirs += "${rootDir}/framework/base/dtd"
> {code}
> I propose to load all dtd present on all active component as this works for
> config directory.
> {code:java}
> diff --git a/build.gradle b/build.gradle
> index 1bc148e636..4c256c74d8 100644
> --- a/build.gradle
> +++ b/build.gradle
> @@ -292,7 +292,7 @@ sourceSets {
> resources {
> srcDirs = getDirectoryInActiveComponentsIfExists('src/main/java')
> srcDirs += getDirectoryInActiveComponentsIfExists('config')
> - srcDirs += "${rootDir}/framework/base/dtd"
> + srcDirs += getDirectoryInActiveComponentsIfExists('dtd')
> exclude excludedJavaSources
> exclude excludedConfigFiles
> // Below are necessary for unit tests run by Gradle and
> integration tests
> {code}
> This solve any connection issue to resolve xsd on ofbiz.apache.org (because
> it use file present on the code base) and the OFBiz start failed linked.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)