public static JaxbPersistence unmarshal(JPAPXml pxml) throws PersistenceException //d86387
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "unmarshal : " + pxml);

        InputStream is = null;
        JaxbPersistence persistence = null;

        try {
            SAXParser parser = ParserFactory.newSAXParser(true, false);
            JaxbUnmarshaller handler = new JaxbUnmarshaller(pxml); // d656864

            is = pxml.openStream();
            parser.parse(is, handler);

            persistence = handler.ivPersistence;
            persistence.setResult(handler.ivHandler.getResult());
        } catch (Throwable ex) {
            FFDCFilter.processException(ex, CLASS_NAME + ".unmarshal", "109", pxml);

            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "  unmarshal : caught exception : " + ex);

            // 7.1.1 Responsibilities of the Container
            //
            // At deployment time the container is responsible for scanning the locations specified
            // in Section 6.2 and discovering the persistence.xml files and processing them.
            //
            // When the container finds a persistence.xml file, it processes the persistence unit
            // definitions that it contains. The container must validate the persistence.xml file
            // against the persistence_1_0.xsd schema and report any validation errors.
            //
            // Provider or data source information not specified in the persistence.xml file must be
            // provided at deployment time or defaulted by the container.

            Throwable root = findRootCause(ex);

            // Log an error message and create a MetaDataException to throw.
            PersistenceException pex = null; // d86387
            String appName = pxml.getApplInfo().getApplName();
            String modName = pxml.getArchiveName();

            if (root instanceof SAXParseException) {
                // Use data in SAXParseException for a more meaningful error message.
                SAXParseException saxEx = (SAXParseException) root;

                // SYNTAX_ERROR_IN_PERSISTENCE_XML_CWWJP0040E=CWWJP0040E:
                // Incorrect syntax or error detected in the persistence.xml
                // file in application: {0}, module: {1}, at line number: {2},
                // column number: {3}. The following associated error message
                // occurred: {4}
                int line = saxEx.getLineNumber();
                int column = saxEx.getColumnNumber();
                Tr.error(tc, "SYNTAX_ERROR_IN_PERSISTENCE_XML_CWWJP0040E", appName, modName, line, column, saxEx);

                pex = new PersistenceException("CWWJP0040E: The persistence.xml" +
                                               " in application " + appName +
                                               ", module " + modName +
                                               ", has a syntax error at line number: " +
                                               line + ", column number: " + column +
                                               ".", saxEx); // d86387
            } else {
                // SAXParseException did not occur, so we must log a more generic error
                // message to indicate some kind of failure occurred while trying to read
                // the persistence.xml file.

                // MALFORMED_PERSISTENCE_XML_CWWJP0018E=CWWJP0018E: Incorrect syntax
                // or error detected in the {0} file. The following associated error
                // message occurred: {1}
                String urlString = pxml.getRootURL().getPath();
                Tr.error(tc, "MALFORMED_PERSISTENCE_XML_CWWJP0018E", urlString, root);

                pex = new PersistenceException("CWWJP0018E: Incorrect syntax " +
                                               "or error detected in " + urlString +
                                               " for application " + appName +
                                               " module " + modName +
                                               ". The following associated error occurred:", root); // 86387
            }

            throw pex;
        } finally {
            // Normally, the close will be performed as soon as possible, to
            // insure the jar file locks are not held (which can be problematic
            // on windows)... but just in case there is a failure before the
            // close() occurs, make sure the close occurs here.
            if (is != null) {
                try {
                    is.close();
                } catch (Throwable ex) {
                    // The only way this occurs is if an exception was already
                    // thrown above... so just log this, and allow the above
                    // exception to flow out of this method.
                    FFDCFilter.processException(ex, CLASS_NAME + ".unmarshal", "192", is);
                    if (isTraceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "  unmarshal : caught exception : " + ex);
                }
            }

            if (isTraceOn && tc.isEntryEnabled())
                Tr.exit(tc, "unmarshal : " + persistence);
        }

        return persistence;
    }
public static JaxbPersistence unmarshal ( JPAPXml pxml ) throws PersistenceException { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "unmarshal : " + pxml ) ; InputStream is = null ; JaxbPersistence persistence = null ; try { SAXParser parser = ParserFactory . newSAXParser ( true , false ) ; JaxbUnmarshaller handler = new JaxbUnmarshaller ( pxml ) ; is = pxml . openStream ( ) ; parser . parse ( is , handler ) ; persistence = handler . ivPersistence ; persistence . setResult ( handler . ivHandler . getResult ( ) ) ; } catch ( Throwable ex ) { FFDCFilter . processException ( ex , CLASS_NAME + ".unmarshal" , "109" , pxml ) ; if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "  unmarshal : caught exception : " + ex ) ; Throwable root = findRootCause ( ex ) ; PersistenceException pex = null ; String appName = pxml . getApplInfo ( ) . getApplName ( ) ; String modName = pxml . getArchiveName ( ) ; if ( root instanceof SAXParseException ) { SAXParseException saxEx = ( SAXParseException ) root ; int line = saxEx . getLineNumber ( ) ; int column = saxEx . getColumnNumber ( ) ; Tr . error ( tc , "SYNTAX_ERROR_IN_PERSISTENCE_XML_CWWJP0040E" , appName , modName , line , column , saxEx ) ; pex = new PersistenceException ( "CWWJP0040E: The persistence.xml" + " in application " + appName + ", module " + modName + ", has a syntax error at line number: " + line + ", column number: " + column + "." , saxEx ) ; } else { String urlString = pxml . getRootURL ( ) . getPath ( ) ; Tr . error ( tc , "MALFORMED_PERSISTENCE_XML_CWWJP0018E" , urlString , root ) ; pex = new PersistenceException ( "CWWJP0018E: Incorrect syntax " + "or error detected in " + urlString + " for application " + appName + " module " + modName + ". The following associated error occurred:" , root ) ; } throw pex ; } finally { if ( is != null ) { try { is . close ( ) ; } catch ( Throwable ex ) { FFDCFilter . processException ( ex , CLASS_NAME + ".unmarshal" , "192" , is ) ; if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "  unmarshal : caught exception : " + ex ) ; } } if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "unmarshal : " + persistence ) ; } return persistence ; }
Determines the correct schema version of the specified persistence.xml
file, and invokes the JAXB unmarshaller using the corresponding
pre-generated JAXB classes for that version. <p>

Non-JAXB, non-version specific objects are returned so the caller
does not need to handle different JAXB packaging per schema version. <p>