logo       

Re: Xerces locks jars when reading schema: msg#00027

Subject: Re: Xerces locks jars when reading schema
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@xxxxxxxxxx
E-mail: mrglavas@xxxxxxxxxx

Prashant Reddy <prashant@xxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxx
> For additional commands, e-mail: j-users-help@xxxxxxxxxxxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe