================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/ejb/cmp3/persistence/PersistenceUnitProcessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_t0essentials_5472691_tomcat_url_fix_060821/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.28 Report generated at Mon Aug 21 14:15:56 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_t0essentials_5472691_tomcat_url_fix_060821/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.28 Mon Aug 21 13:33:53 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/ejb/cmp3/persistence/PersistenceUnitProcessor.java Mon Aug 21 14:15:56 2006 *************** *** 90,96 **** return processPersistenceXML(baseURL, stream, loader); } catch (IOException exc){ ! throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(baseURL, exc); } finally { try{ if (stream != null){ --- 90,96 ---- return processPersistenceXML(baseURL, stream, loader); } catch (IOException exc){ ! throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(baseURL.toString(), exc); } finally { try{ if (stream != null){ *************** *** 176,182 **** List persistenceUnitList = null; // Should be called from JavaSE, and so the url string should still contain // the meta-inf/persistence.xml at the end that should be stripped off to be handled as a file ! URL tempURL = truncateURL(url); try{ persistenceUnitList = processJarFile(tempURL, loader); if (persistenceUnitList != null){ --- 176,182 ---- List persistenceUnitList = null; // Should be called from JavaSE, and so the url string should still contain // the meta-inf/persistence.xml at the end that should be stripped off to be handled as a file ! URL tempURL = truncateURLAndRemoveFileReference(url); try{ persistenceUnitList = processJarFile(tempURL, loader); if (persistenceUnitList != null){ *************** *** 362,383 **** /** * Strips down a URL for a persistence.xml so that it's base can be used to create a file */ ! private static URL truncateURL(URL url) { try{ ! String newURLString = url.toString().substring(0, url.toString().length() - 25); ! if (newURLString.endsWith("!")){ ! newURLString = newURLString.substring(0, newURLString.length() -1); } ! if (newURLString.startsWith("jar:")){ ! newURLString = newURLString.substring(4, newURLString.length()); } ! return new URL(newURLString); } catch (java.net.MalformedURLException exc){ throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(url, exc); } } ! /** * Entries in a zip file are directory entries using slashes to separate them. * Build a class name using '.' instead of slash and removing the '.class' extension. --- 362,399 ---- /** * Strips down a URL for a persistence.xml so that it's base can be used to create a file */ ! private static URL truncateURLAndRemoveFileReference(URL url) { ! String newURLString = url.toString().substring(0, url.toString().length() - 25); ! return createTruncatedJarURLFromString(newURLString); ! ! } ! ! /** ! * Clean up a string that represents a jar. This will create a URL based on the url parameter, but remove ! * a leading 'jar:' and trailing characters starting with the first '!'. The functionality guesses at a URL ! * that a stream can be opened on based on the url parameter. ! * This method is implemented to attempt to provide a URL that can be opened based on a URL retrieved from ! * a classLoader.getResource(String) call on a TomCat deployment. ! * @param url ! * @return ! */ ! private static URL createTruncatedJarURLFromString(String url){ try{ ! String cleanUrl = url; ! int index = url.indexOf('!'); ! if (index > 0){ ! cleanUrl = cleanUrl.substring(0, index); } ! if (cleanUrl.startsWith("jar:")){ ! cleanUrl = cleanUrl.substring(4, cleanUrl.length()); } ! return new URL(cleanUrl); } catch (java.net.MalformedURLException exc){ throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(url, exc); } } ! /** * Entries in a zip file are directory entries using slashes to separate them. * Build a class name using '.' instead of slash and removing the '.class' extension. *************** *** 499,509 **** * @return */ private static List getClassNamesFromJar(URL url){ - JarInputStream jarFile = null; InputStream stream = null; ! List persistentClasses = new Vector(); try { ! stream = url.openStream(); jarFile = new JarInputStream(stream); ZipEntry entry = jarFile.getNextEntry(); if (entry == null){ --- 515,566 ---- * @return */ private static List getClassNamesFromJar(URL url){ InputStream stream = null; ! List persistentClasses = null; ! IOException initialException; try { ! try{ ! // attempt to open a stream on the given URL ! stream = url.openStream(); ! } catch (IOException exc){ ! AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST, JAR_OPENING_EXCEPTION, url, exc); ! initialException = exc; ! try{ ! // guess at an alternate form of the URL to open ! stream = createTruncatedJarURLFromString(url.toString()).openStream(); ! } catch (PersistenceUnitLoadingException exception){ ! AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST, JAR_OPENING_EXCEPTION, url, exception); ! throw initialException; ! } catch (IOException exception2){ ! AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST, JAR_OPENING_EXCEPTION, url, exception2); ! throw initialException; ! } ! } ! persistentClasses = findClassesInJar(stream); ! } catch (IOException exc){ ! throw PersistenceUnitLoadingException.exceptionSearchingForEntities(url, exc); ! } finally { ! try{ ! if (stream != null){ ! stream.close(); ! } ! } catch (IOException exc){}; ! } ! return persistentClasses; ! ! } ! ! /** ! * Convert the given input stream to a jar input stream and look through the entities for classes ! * Return a list of those classes ! * @param stream ! * @return ! * @throws IOException ! */ ! private static List findClassesInJar(InputStream stream) throws IOException { ! JarInputStream jarFile = null; ! List persistentClasses = new Vector(); ! try{ jarFile = new JarInputStream(stream); ZipEntry entry = jarFile.getNextEntry(); if (entry == null){ *************** *** 516,528 **** } entry = jarFile.getNextEntry(); } - } catch (IOException exc){ - throw PersistenceUnitLoadingException.exceptionSearchingForEntities(url, exc); } finally { try{ - if (stream != null){ - stream.close(); - } if (jarFile != null){ jarFile.close(); } --- 573,580 ---- *************** *** 530,536 **** } return persistentClasses; } ! /** * Return a list of class names from this URL. This will work either with directories * or jar files and assume the classes are based in the base directory of the URL --- 582,588 ---- } return persistentClasses; } ! /** * Return a list of class names from this URL. This will work either with directories * or jar files and assume the classes are based in the base directory of the URL ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/exceptions/PersistenceUnitLoadingException.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_t0essentials_5472691_tomcat_url_fix_060821/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.10 Report generated at Mon Aug 21 14:15:56 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_t0essentials_5472691_tomcat_url_fix_060821/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.10 Mon Aug 21 13:34:11 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/exceptions/PersistenceUnitLoadingException.java Mon Aug 21 14:15:56 2006 *************** *** 89,95 **** return loadingException; } ! public static PersistenceUnitLoadingException exceptionLoadingFromUrl(URL url, Exception cause) { Object[] args = { url }; PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_LOADING_FROM_URL, args), cause); --- 89,95 ---- return loadingException; } ! public static PersistenceUnitLoadingException exceptionLoadingFromUrl(String url, Exception cause) { Object[] args = { url }; PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_LOADING_FROM_URL, args), cause); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/ejb/cmp3/persistence/PersistenceUnitProcessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_t0essentials_5472691_tomcat_url_fix_060821/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.28 Report generated at Mon Aug 21 14:16:18 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_t0essentials_5472691_tomcat_url_fix_060821/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.28 Mon Aug 21 13:33:53 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/ejb/cmp3/persistence/PersistenceUnitProcessor.java Mon Aug 21 14:15:56 2006 *************** *** 90,96 **** return processPersistenceXML(baseURL, stream, loader); } catch (IOException exc){ ! throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(baseURL, exc); } finally { try{ if (stream != null){ --- 90,96 ---- return processPersistenceXML(baseURL, stream, loader); } catch (IOException exc){ ! throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(baseURL.toString(), exc); } finally { try{ if (stream != null){ *************** *** 176,182 **** List persistenceUnitList = null; // Should be called from JavaSE, and so the url string should still contain // the meta-inf/persistence.xml at the end that should be stripped off to be handled as a file ! URL tempURL = truncateURL(url); try{ persistenceUnitList = processJarFile(tempURL, loader); if (persistenceUnitList != null){ --- 176,182 ---- List persistenceUnitList = null; // Should be called from JavaSE, and so the url string should still contain // the meta-inf/persistence.xml at the end that should be stripped off to be handled as a file ! URL tempURL = truncateURLAndRemoveFileReference(url); try{ persistenceUnitList = processJarFile(tempURL, loader); if (persistenceUnitList != null){ *************** *** 362,383 **** /** * Strips down a URL for a persistence.xml so that it's base can be used to create a file */ ! private static URL truncateURL(URL url) { try{ ! String newURLString = url.toString().substring(0, url.toString().length() - 25); ! if (newURLString.endsWith("!")){ ! newURLString = newURLString.substring(0, newURLString.length() -1); } ! if (newURLString.startsWith("jar:")){ ! newURLString = newURLString.substring(4, newURLString.length()); } ! return new URL(newURLString); } catch (java.net.MalformedURLException exc){ throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(url, exc); } } ! /** * Entries in a zip file are directory entries using slashes to separate them. * Build a class name using '.' instead of slash and removing the '.class' extension. --- 362,399 ---- /** * Strips down a URL for a persistence.xml so that it's base can be used to create a file */ ! private static URL truncateURLAndRemoveFileReference(URL url) { ! String newURLString = url.toString().substring(0, url.toString().length() - 25); ! return createTruncatedJarURLFromString(newURLString); ! ! } ! ! /** ! * Clean up a string that represents a jar. This will create a URL based on the url parameter, but remove ! * a leading 'jar:' and trailing characters starting with the first '!'. The functionality guesses at a URL ! * that a stream can be opened on based on the url parameter. ! * This method is implemented to attempt to provide a URL that can be opened based on a URL retrieved from ! * a classLoader.getResource(String) call on a TomCat deployment. ! * @param url ! * @return ! */ ! private static URL createTruncatedJarURLFromString(String url){ try{ ! String cleanUrl = url; ! int index = url.indexOf('!'); ! if (index > 0){ ! cleanUrl = cleanUrl.substring(0, index); } ! if (cleanUrl.startsWith("jar:")){ ! cleanUrl = cleanUrl.substring(4, cleanUrl.length()); } ! return new URL(cleanUrl); } catch (java.net.MalformedURLException exc){ throw PersistenceUnitLoadingException.exceptionLoadingFromUrl(url, exc); } } ! /** * Entries in a zip file are directory entries using slashes to separate them. * Build a class name using '.' instead of slash and removing the '.class' extension. *************** *** 499,509 **** * @return */ private static List getClassNamesFromJar(URL url){ - JarInputStream jarFile = null; InputStream stream = null; ! List persistentClasses = new Vector(); try { ! stream = url.openStream(); jarFile = new JarInputStream(stream); ZipEntry entry = jarFile.getNextEntry(); if (entry == null){ --- 515,566 ---- * @return */ private static List getClassNamesFromJar(URL url){ InputStream stream = null; ! List persistentClasses = null; ! IOException initialException; try { ! try{ ! // attempt to open a stream on the given URL ! stream = url.openStream(); ! } catch (IOException exc){ ! AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST, JAR_OPENING_EXCEPTION, url, exc); ! initialException = exc; ! try{ ! // guess at an alternate form of the URL to open ! stream = createTruncatedJarURLFromString(url.toString()).openStream(); ! } catch (PersistenceUnitLoadingException exception){ ! AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST, JAR_OPENING_EXCEPTION, url, exception); ! throw initialException; ! } catch (IOException exception2){ ! AbstractSessionLog.getLog().log(AbstractSessionLog.FINEST, JAR_OPENING_EXCEPTION, url, exception2); ! throw initialException; ! } ! } ! persistentClasses = findClassesInJar(stream); ! } catch (IOException exc){ ! throw PersistenceUnitLoadingException.exceptionSearchingForEntities(url, exc); ! } finally { ! try{ ! if (stream != null){ ! stream.close(); ! } ! } catch (IOException exc){}; ! } ! return persistentClasses; ! ! } ! ! /** ! * Convert the given input stream to a jar input stream and look through the entities for classes ! * Return a list of those classes ! * @param stream ! * @return ! * @throws IOException ! */ ! private static List findClassesInJar(InputStream stream) throws IOException { ! JarInputStream jarFile = null; ! List persistentClasses = new Vector(); ! try{ jarFile = new JarInputStream(stream); ZipEntry entry = jarFile.getNextEntry(); if (entry == null){ *************** *** 516,528 **** } entry = jarFile.getNextEntry(); } - } catch (IOException exc){ - throw PersistenceUnitLoadingException.exceptionSearchingForEntities(url, exc); } finally { try{ - if (stream != null){ - stream.close(); - } if (jarFile != null){ jarFile.close(); } --- 573,580 ---- *************** *** 530,536 **** } return persistentClasses; } ! /** * Return a list of class names from this URL. This will work either with directories * or jar files and assume the classes are based in the base directory of the URL --- 582,588 ---- } return persistentClasses; } ! /** * Return a list of class names from this URL. This will work either with directories * or jar files and assume the classes are based in the base directory of the URL ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/exceptions/PersistenceUnitLoadingException.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_t0essentials_5472691_tomcat_url_fix_060821/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.10 Report generated at Mon Aug 21 14:16:18 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_t0essentials_5472691_tomcat_url_fix_060821/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.10 Mon Aug 21 13:34:11 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/exceptions/PersistenceUnitLoadingException.java Mon Aug 21 14:15:56 2006 *************** *** 89,95 **** return loadingException; } ! public static PersistenceUnitLoadingException exceptionLoadingFromUrl(URL url, Exception cause) { Object[] args = { url }; PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_LOADING_FROM_URL, args), cause); --- 89,95 ---- return loadingException; } ! public static PersistenceUnitLoadingException exceptionLoadingFromUrl(String url, Exception cause) { Object[] args = { url }; PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_LOADING_FROM_URL, args), cause);