You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Prashant Reddy <pr...@pramati.com> on 2007/05/15 17:13:45 UTC

Xerces locks jars when reading schema

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6457007

Reproduction:
1. Build DOM of an XML whose XSD is locally resolved to a JAR file. 

Although the bug in the Sun's database seems to suggest this issue goes
away if one employs 2.8 version of Xerces, my experience has been the
contrary. 

In my deployment scenario i have used endorsed.dirs and overrode the
bundled xerces implementation with 2.8 and the problem outlined in the
bug description quoted above still remains.

If the JAR containing the XSD is part of WEB-INF/lib of a application
such locking of jar may result in failure to clean-up when you undeploy
the application from a Servlet container.

Also nothing in the current code[1] seem to suggest the bug is resolved
as yet ?

I cannot think of what the solution can be though, since URLConnection
does not have any close()/disconnect() method that actually calls the
ZipFile's close() method.

The stack trace which opens the Jar File containing the XSD is the
following :

     java.util.jar.JarFile.<init>(java\util\jar\JarFile.java:134)
     java.util.jar.JarFile.<init>(java\util\jar\JarFile.java:70)
 sun.net.www.protocol.jar.URLJarFile.<init>(sun\net\www\protocol\jar
\URLJarFi
 le.java:56)
 sun.net.www.protocol.jar.URLJarFile.getJarFile(sun\net\www\protocol\jar
\URLJ
 arFile.java:41)
 sun.net.www.protocol.jar.JarFileFactory.get(sun\net\www\protocol\jar
\JarFile
 Factory.java:63)
 sun.net.www.protocol.jar.JarURLConnection.connect(sun\net\www\protocol
\jar\J
 arURLConnection.java:85)
 sun.net.www.protocol.jar.JarURLConnection.getInputStream(sun\net\www
\protoco
 l\jar\JarURLConnection.java:107)
 org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(-unknown-:-1)
     org.apache.xerces.impl.XMLEntityManager.startEntity(-unknown-:-1)
 org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(-unknown-:-1)
 org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(-unknown-:-1)

org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(-unknown-:-1)

org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(-unknown-:-1)
     org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(-unknown-:-1)
 org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(-unknown-:
 -1)
 org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(-unknown-:-1)
     org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(-unknown-:-1)
 org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(-unknown-:-1)

 org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(-unknown-:-1
 )
 org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(-unknown-:-1)
 org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(-unknown-:-
 1)
 org.apache.xerces.impl.XMLNSDocumentScannerImpl
$NSContentDispatcher.scanRoot
 ElementHook(-unknown-:-1)
 org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatc
 her.dispatch(-unknown-:-1)
 org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(-unknown-
 :-1)
     org.apache.xerces.parsers.XML11Configuration.parse(-unknown-:-1)
     org.apache.xerces.parsers.XML11Configuration.parse(-unknown-:-1)
     org.apache.xerces.parsers.XMLParser.parse(-unknown-:-1)
     org.apache.xerces.parsers.DOMParser.parse(-unknown-:-1)
     org.apache.xerces.jaxp.DocumentBuilderImpl.parse(-unknown-:-1)
     javax.xml.parsers.DocumentBuilder.parse(-unknown-:-1)

Thank you for your time.

[1]
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityManager.java?view=markup
-- 

-Prashant

Don't upload, just share : www.dekoh.com


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Xerces locks jars when reading schema

Posted by Prashant Reddy <pr...@pramati.com>.
Looks like I am not alone in this. Please see:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399836

-Prashant

On Tue, 2007-05-15 at 20:43 +0530, Prashant Reddy wrote:
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6457007
> 
> Reproduction:
> 1. Build DOM of an XML whose XSD is locally resolved to a JAR file. 
> 
> Although the bug in the Sun's database seems to suggest this issue goes
> away if one employs 2.8 version of Xerces, my experience has been the
> contrary. 
> 
> In my deployment scenario i have used endorsed.dirs and overrode the
> bundled xerces implementation with 2.8 and the problem outlined in the
> bug description quoted above still remains.
> 
> If the JAR containing the XSD is part of WEB-INF/lib of a application
> such locking of jar may result in failure to clean-up when you undeploy
> the application from a Servlet container.
> 
> Also nothing in the current code[1] seem to suggest the bug is resolved
> as yet ?
> 
> I cannot think of what the solution can be though, since URLConnection
> does not have any close()/disconnect() method that actually calls the
> ZipFile's close() method.
> 
> The stack trace which opens the Jar File containing the XSD is the
> following :
> 
>      java.util.jar.JarFile.<init>(java\util\jar\JarFile.java:134)
>      java.util.jar.JarFile.<init>(java\util\jar\JarFile.java:70)
>  sun.net.www.protocol.jar.URLJarFile.<init>(sun\net\www\protocol\jar
> \URLJarFi
>  le.java:56)
>  sun.net.www.protocol.jar.URLJarFile.getJarFile(sun\net\www\protocol\jar
> \URLJ
>  arFile.java:41)
>  sun.net.www.protocol.jar.JarFileFactory.get(sun\net\www\protocol\jar
> \JarFile
>  Factory.java:63)
>  sun.net.www.protocol.jar.JarURLConnection.connect(sun\net\www\protocol
> \jar\J
>  arURLConnection.java:85)
>  sun.net.www.protocol.jar.JarURLConnection.getInputStream(sun\net\www
> \protoco
>  l\jar\JarURLConnection.java:107)
>  org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(-unknown-:-1)
>      org.apache.xerces.impl.XMLEntityManager.startEntity(-unknown-:-1)
>  org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(-unknown-:-1)
>  org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(-unknown-:-1)
> 
> org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(-unknown-:-1)
> 
> org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(-unknown-:-1)
>      org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(-unknown-:-1)
>  org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(-unknown-:
>  -1)
>  org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(-unknown-:-1)
>      org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(-unknown-:-1)
>  org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(-unknown-:-1)
> 
>  org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(-unknown-:-1
>  )
>  org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(-unknown-:-1)
>  org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(-unknown-:-
>  1)
>  org.apache.xerces.impl.XMLNSDocumentScannerImpl
> $NSContentDispatcher.scanRoot
>  ElementHook(-unknown-:-1)
>  org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
> $FragmentContentDispatc
>  her.dispatch(-unknown-:-1)
>  org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(-unknown-
>  :-1)
>      org.apache.xerces.parsers.XML11Configuration.parse(-unknown-:-1)
>      org.apache.xerces.parsers.XML11Configuration.parse(-unknown-:-1)
>      org.apache.xerces.parsers.XMLParser.parse(-unknown-:-1)
>      org.apache.xerces.parsers.DOMParser.parse(-unknown-:-1)
>      org.apache.xerces.jaxp.DocumentBuilderImpl.parse(-unknown-:-1)
>      javax.xml.parsers.DocumentBuilder.parse(-unknown-:-1)
> 
> Thank you for your time.
> 
> [1]
> http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityManager.java?view=markup



---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Xerces locks jars when reading schema

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Prashant,

Xerces closes every Reader (which in turn closes the InputStream) when its 
finished reading from it.

XMLEntityManager :: Line 1941:
        // Close the reader for the current entity once we're 
        // done with it, and remove it from our stack. If parsing
        // is halted at some point, the rest of the readers on
        // the stack will be closed during cleanup.
        try {
            fCurrentEntity.reader.close();
        }
        catch (IOException e) {
            // ignore
        }

XMLEntityManager :: Line 1226:
    public void closeReaders() {
        // close all readers
        for (int i = fReaderStack.size()-1; i >= 0; i--) {
            try {
                ((Reader)fReaderStack.pop()).close();
            } catch (IOException e) {
                // ignore
            }
        }
    }

If calling close() doesn't unlock the jar based on what you've said it 
doesn't sound like there's anything else that we can do about it.

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Prashant Reddy <pr...@pramati.com> wrote on 05/15/2007 11:13:45 AM:

> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6457007
> 
> Reproduction:
> 1. Build DOM of an XML whose XSD is locally resolved to a JAR file. 
> 
> Although the bug in the Sun's database seems to suggest this issue goes
> away if one employs 2.8 version of Xerces, my experience has been the
> contrary. 
> 
> In my deployment scenario i have used endorsed.dirs and overrode the
> bundled xerces implementation with 2.8 and the problem outlined in the
> bug description quoted above still remains.
> 
> If the JAR containing the XSD is part of WEB-INF/lib of a application
> such locking of jar may result in failure to clean-up when you undeploy
> the application from a Servlet container.
> 
> Also nothing in the current code[1] seem to suggest the bug is resolved
> as yet ?
> 
> I cannot think of what the solution can be though, since URLConnection
> does not have any close()/disconnect() method that actually calls the
> ZipFile's close() method.
> 
> The stack trace which opens the Jar File containing the XSD is the
> following :
> 
>      java.util.jar.JarFile.<init>(java\util\jar\JarFile.java:134)
>      java.util.jar.JarFile.<init>(java\util\jar\JarFile.java:70)
>  sun.net.www.protocol.jar.URLJarFile.<init>(sun\net\www\protocol\jar
> \URLJarFi
>  le.java:56)
>  sun.net.www.protocol.jar.URLJarFile.getJarFile(sun\net\www\protocol\jar
> \URLJ
>  arFile.java:41)
>  sun.net.www.protocol.jar.JarFileFactory.get(sun\net\www\protocol\jar
> \JarFile
>  Factory.java:63)
>  sun.net.www.protocol.jar.JarURLConnection.connect(sun\net\www\protocol
> \jar\J
>  arURLConnection.java:85)
>  sun.net.www.protocol.jar.JarURLConnection.getInputStream(sun\net\www
> \protoco
>  l\jar\JarURLConnection.java:107)
> org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(-unknown-:-1)
>      org.apache.xerces.impl.XMLEntityManager.startEntity(-unknown-:-1)
> 
org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(-unknown-:-1)
> 
org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(-unknown-:-1)
> 
> org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(-unknown-:-1)
> 
> org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(-unknown-:-1)
>      org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(-unknown-:-1)
> 
org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(-unknown-:
>  -1)
> 
org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(-unknown-:-1)
>      org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(-unknown-:-1)
> 
org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(-unknown-:-1)
> 
> 
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(-unknown-:-1
>  )
>  org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(-unknown-:-1)
> 
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(-unknown-:-
>  1)
>  org.apache.xerces.impl.XMLNSDocumentScannerImpl
> $NSContentDispatcher.scanRoot
>  ElementHook(-unknown-:-1)
>  org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
> $FragmentContentDispatc
>  her.dispatch(-unknown-:-1)
> 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(-unknown-
>  :-1)
>      org.apache.xerces.parsers.XML11Configuration.parse(-unknown-:-1)
>      org.apache.xerces.parsers.XML11Configuration.parse(-unknown-:-1)
>      org.apache.xerces.parsers.XMLParser.parse(-unknown-:-1)
>      org.apache.xerces.parsers.DOMParser.parse(-unknown-:-1)
>      org.apache.xerces.jaxp.DocumentBuilderImpl.parse(-unknown-:-1)
>      javax.xml.parsers.DocumentBuilder.parse(-unknown-:-1)
> 
> Thank you for your time.
> 
> [1]
> http://svn.apache.
> 
org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityManager.
> java?view=markup
> -- 
> 
> -Prashant
> 
> Don't upload, just share : www.dekoh.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org