[
https://issues.apache.org/jira/browse/OFBIZ-12118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17262744#comment-17262744
]
Daniel Watford commented on OFBIZ-12118:
----------------------------------------
When running ofbiz from the command line using gradle, the URLs passed to
UtilXml.readXmlDocument are file URLs, e.g.
{{[file:/ofbiz/build/resources/main/component-load.xml|file://ofbiz/build/resources/main/component-load.xml]}}
If running ofbiz from the ofbiz.jar file then the URLs passed to
UtilXml.readXmlDocument refer to resources in jar files, e.g.
{{jar:[file:/ofbiz/build/distributions/foo/ofbiz/lib/ofbiz.jar!/component-load.xml|file://ofbiz/build/distributions/foo/ofbiz/lib/ofbiz.jar!/component-load.xml]}}
There are a few JDK bugs related to caching of stream for URL resources,
including:
- [Bug ID: JDK-6947916 JarURLConnection does not handle useCaches correctly
(java.com)|https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6947916]
- [Bug ID: JDK-8155607 Closing an URLClassLoader instance affect another
URLClassLoader instance when getResourceAsStream() is being used
(java.com)|https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8155607]
The first bug is related to using caches with JarUrlConnections and is thought
to be fixed. However the second bug about closing a URLClassLoader seems very
similar in that file input streams are being closed unexpectedly.
Checking URLClassLoader sources, it does indeed use URLConnection to access jar
files. I wonder if the issue we are experiencing is due to the URLClassLoader
also accessing, and subsequently closing, ofbiz.jar before our
UtilXml.readXmlDocument gets a chance to run.
Based on this, avoiding use of caches when dealing URLConnections, unless you
know that no other thread is accessing the same resources, seems reasonable and
[~ieugen]'s PR should be applied to ofbiz.
> OFBiz XML parsing issue when starting from a ofbiz.tar build - files missing
> from ofbiz.tar
> -------------------------------------------------------------------------------------------
>
> Key: OFBIZ-12118
> URL: https://issues.apache.org/jira/browse/OFBIZ-12118
> Project: OFBiz
> Issue Type: Bug
> Components: ALL APPLICATIONS
> Affects Versions: Trunk
> Reporter: Ioan Eugen Stan
> Priority: Major
>
> Discussion:
> [https://lists.apache.org/thread.html/r658047067bae1b776d60ac90bc03cfba56f718feaca0eb10209020bb%40%3Cuser.ofbiz.apache.org%3E]
>
> ---
> I can't start OFBiz from the built ofbiz.tar .
> My goal is to build ofbiz.tar and use it to build a docker image.
>
> Then use the image to deploy instances of OFBiz:
> - load data
> - run OFBiz
>
> [source,bash]
> ----
>
> ./gradlew clean pullAllPluginsSource build
>
>
> ./bin/ofbiz --load-data readers=seed,seed-initial,ext,ext-demo
>
> Config.java using configuration file load-data.properties
> Set OFBIZ_HOME to -
> /home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz
> Shutdown hook disabled
> 2021-01-05 12:00:10,622 |main |UtilXml {{|E|}}
> XmlFileLoader: File
> [jar:file:/home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml|jar:file:///home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml]
> process warning. Line: 22. Error message: schema_reference.4: Failed to read
> schema document 'null', 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>.
> 2021-01-05 12:00:10,627 |main |UtilXml {{|E|}}
> XmlFileLoader: File
> [jar:file:/home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml|jar:file:///home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml]
> process error. Line: 22. Error message: cvc-elt.1.a: Cannot find the
> declaration of element 'component-loader'.
> org.apache.ofbiz.base.start.StartupException: Cannot init()
> component-container (org.apache.ofbiz.base.component.ComponentException:
> Error reading the component config file:
> [jar:file:/home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml|jar:file:///home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml]
> (Stream closed) (Error reading the component config file:
> [jar:file:/home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml|jar:file:///home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml]
> (Stream closed)))
> at
> org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:69)
> at
> org.apache.ofbiz.base.start.StartupControlPanel.loadContainers(StartupControlPanel.java:146)
>
> at
> org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:70)
>
> at org.apache.ofbiz.base.start.Start.main(Start.java:89)
> Caused by: org.apache.ofbiz.base.container.ContainerException:
> org.apache.ofbiz.base.component.ComponentException: Error reading the
> component config file:
> [jar:file:/home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml|jar:file:///home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml]
> (Stream closed) (Error reading the component config file:
> [jar:file:/home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml|jar:file:///home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml]
> (Stream closed))
> at
> org.apache.ofbiz.base.container.ComponentContainer.init(ComponentContainer.java:79)
>
> at
> org.apache.ofbiz.base.container.ComponentContainer.init(ComponentContainer.java:57)
>
> at
> org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:66)
> ... 3 more
> Caused by: org.apache.ofbiz.base.component.ComponentException: Error reading
> the component config file:
> [jar:file:/home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml|jar:file:///home/ieugen/proiecte/ofbiz/ofbiz-framework/build/distributions/ofbiz/lib/ofbiz.jar!/component-load.xml]
> (Stream closed)
> at
> org.apache.ofbiz.base.component.ComponentLoaderConfig.parseDocumentFromUrl(ComponentLoaderConfig.java:168)
>
> at
> org.apache.ofbiz.base.component.ComponentLoaderConfig.getComponentsFromConfig(ComponentLoaderConfig.java:80)
>
> at
> org.apache.ofbiz.base.component.ComponentLoaderConfig.getRootComponents(ComponentLoaderConfig.java:70)
>
> at
> org.apache.ofbiz.base.container.ComponentContainer.init(ComponentContainer.java:74)
>
> ... 5 more
> Caused by: java.io.IOException: Stream closed
> at
> java.util.zip.InflaterInputStream.ensureOpen(InflaterInputStream.java:67)
> at
> java.util.zip.InflaterInputStream.read(InflaterInputStream.java:142)
> at java.io.FilterInputStream.read(FilterInputStream.java:133)
> at
> org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.read(Unknown
> Source)
> at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
> at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
> at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
> at
> org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
> at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
> at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
> at
> org.apache.ofbiz.base.util.UtilXml.readXmlDocument(UtilXml.java:443)
> at
> org.apache.ofbiz.base.util.UtilXml.readXmlDocument(UtilXml.java:383)
> at
> org.apache.ofbiz.base.component.ComponentLoaderConfig.parseDocumentFromUrl(ComponentLoaderConfig.java:166)
>
> ... 8 more
>
> ---
>
>
> NOTE: I'm working on building a docker image for OFBiz and I've made some
> progress. I will share my work and try to merge it upstream.
>
>
> NOTE: I'm using: commit ba5536fe5735fcddc7eb8b515372cab932c0a913 Improved:
> Apply CSS Grid to Find Orders (OFBIZ-12116)
>
> NOTE: java -version
> openjdk version "1.8.0_275"
> OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_275-b01)
> OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.275-b01, mixed mode)
>
>
> p.s. The ofbiz build is quite large at ~450MB
--
This message was sent by Atlassian Jira
(v8.3.4#803005)