Community
Participate
Working Groups
Build Identifier: 2.3.0.v20110604-r9504 I upgrade my application to RAP 1.4 that is based on eclipse 3.7 indingo. In PDE (workspace) mode all works well, but when create and deploy WAR MalformedURLException was thrown when xerces parse persistence.xml. After hours of investigations if found the problem. PersistenceUnitProcessor.computePURootURL() doesn't handle URL of type bundleresource, it pass URL forward as is. When ArchiveFactoryImpl.createArchive(URL,String,Map) create the Archive object, it switch on url protocol and the method isJarInputStream() under eclipse 3.6.2 return false but under eclipse 3.7 return true. So with eclipse 3.6.2 ArchiveFactoryImpl return a URLArchive instead under eclipse 3.7 return a JarInputStreamURLArchive. isJarInputStream test if is a jar or not as the follow: protected boolean isJarInputStream(URL url) throws IOException { InputStream in = null; try { in = url.openStream(); if (in == null) { // for directories, we may get InputStream as null return false; } ... in eclipse the final object that connect and open the stream is a DirZipBundleEntry class that when is invoked getInputStream() return always null under eclipse 3.6.2: public InputStream getInputStream() throws IOException { return null; } in eclipse 3.7 it return a empty array of ByteArrayInputStream public InputStream getInputStream() throws IOException { return new ByteArrayInputStream(new byte[0]); } When JarInputStreamURLArchive should compute entries it returns none and break the XML parser of persistence.xml This problem happens with builds of eclipselink 2.1.2 to 2.3.0 This is blocking to deploy applications with eclipse 3.7. Reproducible: Always
To avoid this problem and deploy, I have implement a new ArchiveFactory that extends ArchiveFactoryImpl in a new fragment (due to classloader method used into persistence.jpa plugin). This new Factory only override createArchive method. public class OSGiArchiveFactoryImpl extends ArchiveFactoryImpl { ... @Override public Archive createArchive ... ... if (rootUrl == null) { return null; } Archive result = null; String protocol = rootUrl.getProtocol(); logger.logp(Level.FINER, sourceClass, "createArchive", "protocol = {0}", protocol); if ("file".equals(protocol) || "jar".equals(protocol)) { // NOI18N return super.createArchive(rootUrl, descriptorLocation, properties); } else if ("bundleresource".equals(protocol)) { rootUrl = FileLocator.resolve(rootUrl); protocol = rootUrl.getProtocol(); if (!"bundleresource".equals(protocol)) result = createArchive(rootUrl, descriptorLocation, properties); else result = new URLArchive(rootUrl, descriptorLocation); } else { result = new URLArchive(rootUrl, descriptorLocation); } logger.exiting(sourceClass, "createArchive", result); return result; } }
Sorry, I press "Save Changes" button with a combo of tab+space -_- Missing define a JVM property -Declipselink.archive.factory=my.OSGiArchiveFactoryImpl into WebSphere or jetty application (better if a standard META-INF/service mechanism was used, or a different method to read also OSGi property). In my case is not possible define the system property into an activator, because is to late (and fragment can't have activator).
'any chance this is a duplicate of: https://bugs.eclipse.org/bugs/show_bug.cgi?id=355484
yes, with eclipselink 2.3.1 (not yet published) works without my workaround.
*** This bug has been marked as a duplicate of bug 355484 ***
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink