During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #758848] |
Thu, 24 November 2011 12:39  |
Eclipse User |
|
|
|
Hello,
I've been using Gemini JPA over the past month with much success. Everything works nicely when running my product through the eclipse IDE. Unfortunately, I've encountered a series of problems while running they deployed product (deployed using the Product Export Wizard). This current problem has me a little stumped.
I'm running in an OSGi environment (equinox). I have a persistence bundle which the persistence unit xml file and entity classes.
When I attempt to "createEntityManagerFactory", I get a chain of exceptions which indicates a null URL. Unfortunately, I can't tell which URL is null, or why it is null in the release build and not in the eclipse ide environment. Perhaps your familiarity with the internal flow can uickly shed some light on what I'm missing, or what I should look for -- or which additional information you might need.
Unfortunately, it looks like the exception that might be giving me the information I need is being interrupted by another minor exception.
I'll keep perusing the code on your SCM webviews in the meantime.
Thanks for your help, and the technology.
Thanks,
Darren.
Attempting getResources(META-INF/persistence.xml) on org.eclipse.gemini.jpa.classloader.BundleProxyClassLoader@c25480([OUR PERSISTENCE BUNDLE #90])
Found resources(META-INF/persistence.xml) from org.eclipse.gemini.jpa.classloader.BundleProxyClassLoader@c25480([OUR PERSISTENCE BUNDLE #90])
Attempting getResources(META-INF/persistence.xml) on org.eclipse.gemini.jpa.classloader.BundleProxyClassLoader@39a91f(org.eclipse.gemini.jpa)
Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: org.eclipse.gemini.jpa.classloader.CompositeClassLoader@18e3c98
Internal Exception: Exception [EclipseLink-30009] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while trying to load persistence unit at url: bundleresource://90.fwk8238128
Internal Exception: Exception [EclipseLink-30004] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while processing persistence.xml from URL: bundleresource://90.fwk8238128
Internal Exception: java.net.MalformedURLException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:115)
at org.eclipse.gemini.jpa.provider.EclipseLinkOSGiProvider.createEntityManagerFactory(EclipseLinkOSGiProvider.java:278)
at org.eclipse.gemini.jpa.proxy.EMFServiceProxyHandler.createEMF(EMFServiceProxyHandler.java:128)
at org.eclipse.gemini.jpa.proxy.EMFBuilderServiceProxyHandler.createEMF(EMFBuilderServiceProxyHandler.java:107)
at org.eclipse.gemini.jpa.proxy.EMFServiceProxyHandler.syncGetEMFAndSetIfAbsent(EMFServiceProxyHandler.java:106)
at org.eclipse.gemini.jpa.proxy.EMFBuilderServiceProxyHandler.invoke(EMFBuilderServiceProxyHandler.java:96)
at $Proxy13.createEntityManagerFactory(Unknown Source)
at org.eclipse.persistence.javax.persistence.osgi.OSGiProviderResolver.lookupEMFBuilder(Unknown Source)
at org.eclipse.persistence.javax.persistence.osgi.OSGiProviderResolver.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at [OUR CODE]
Caused by: Exception [EclipseLink-30009] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while trying to load persistence unit at url: bundleresource://90.fwk8238128
Internal Exception: Exception [EclipseLink-30004] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while processing persistence.xml from URL: bundleresource://90.fwk8238128
Internal Exception: java.net.MalformedURLException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionLoadingFromUrl(PersistenceUnitLoadingException.java:99)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceArchive(PersistenceUnitProcessor.java:538)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.getPersistenceUnits(PersistenceUnitProcessor.java:444)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchive(JPAInitializer.java:172)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:154)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:135)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:73)
... 56 more
Caused by: Exception [EclipseLink-30004] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while processing persistence.xml from URL: bundleresource://90.fwk8238128
Internal Exception: java.net.MalformedURLException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionProcessingPersistenceXML(PersistenceUnitLoadingException.java:117)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:579)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceArchive(PersistenceUnitProcessor.java:536)
... 61 more
Caused by: java.net.MalformedURLException
at java.net.URL.<init>(URL.java:617)
at java.net.URL.<init>(URL.java:480)
at java.net.URL.<init>(URL.java:429)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:626)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:189)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:799)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:577)
... 62 more
Caused by: java.lang.NullPointerException
at java.net.URL.<init>(URL.java:522)
... 72 more
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #1810240 is a reply to message #764682] |
Mon, 05 August 2019 15:30  |
Eclipse User |
|
|
|
I know this is a late reply, but I found the root cause of this bug: DirectoryInsideJarURLArchive.java, line 88, is incompatible with line 99 (EclipseLink 2.7.4).
SPECIFICALLY: the entry being added (e.g., "BOOT-INF/classes/META-INF/persistence.xml") is getting the relativeRootPath ("BOOT-INF/classes") stripped off in line 88, and in line 99, the relativeRootPath is being prepended to the entry (only, when it got stripped off, the separator got stripped off with it, and it is not added back in during lookup):
before: "BOOT-INF/classes/META-INF/persistence.xml"
relativeRootPath: "BOOT-INF/classes"
entry: "META-INF/persistence.xml"
after: "BOOT-INF/classesMETA-INF/persistence.xml"
Resulting in an NPE.
WORKAROUND: put the `META-INF/persistence.xml` in the root of the jar file.
// lines 77 through 91
private void init() {
for(Enumeration<JarEntry> jarEntries = jarFile.entries();
jarEntries.hasMoreElements();) {
JarEntry jarEntry = jarEntries.nextElement();
if(jarEntry.isDirectory()) {
continue;
}
String jarEntryName = jarEntry.getName();
if (relativeRootPath==null) {
entries.add(jarEntryName);
} else if (jarEntryName.startsWith(relativeRootPath)) {
entries.add(jarEntryName.substring(relativeRootPath.length())); // <-- too eager
}
}
}
// lines 97 through 101
public InputStream getEntry(String entryPath) throws IOException {
InputStream is = entries.contains(entryPath) ?
jarFile.getInputStream(jarFile.getEntry(relativeRootPath + entryPath)) : null; // <-- or this needs to add separator "/" back
return is;
}
I am not a regular user of EclipseLink, and have no idea if what seems like a simple fix would have other consequences, but it "feels" self-contained.
Nevertheless, it would be great to fix this so it would be more compatible with Spring Boot without having to hack up the build script to put the persistence.xml in a strange place.
|
|
|
Powered by
FUDForum. Page generated in 0.03939 seconds