During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #758848] |
Thu, 24 November 2011 17: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 #759056 is a reply to message #758878] |
Fri, 25 November 2011 20:57 |
Eclipse User |
|
|
|
Hello.
I attached a debugger to investigate what was going on prior to the MalformedURLException (which is really a wrapped NullPointerException), and have identified some points where additional error checking may help the project:
org.eclipse.persistence.internal.jpa.deployment.JarInputStreamURLArchive.getEntry(String) line: 83
The 'entries' collection is empty, so a null InputStream is returned.
When this null InputStream arrives in:
org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceArchive(Archive, ClassLoader) line: 536
It is used in a call:
org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(URL, InputStream, ClassLoader) line: 547
This function creates a new InputSource
InputSource inputSource = new InputSource([null]);
Which causes problems shortly after when it is used for parsing...
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(InputSource) line: 561
The null becomes a problem a few levels within .parse resulting in the MalformedURL
Hopefully this information is helpful.
So next, I must investigate why the JarInputStreamURLArchive had no entries -- which may technically out of the domain of gemini. I will post back when I learn more.
|
|
|
|
|
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #759072 is a reply to message #759063] |
Fri, 25 November 2011 22:35 |
Eclipse User |
|
|
|
I was able to circumvent the problem by deploying my persistence bundles in directory format instead of the default jar format. It seems that some of the time, the underlying systems are unable to access the contents of the jar to read META-INF/persistence.xml, despite being able to access it at other times* (possibly through other means).
How to make a eclipse plug-in deploy in folder / directory form:
Include this line in the bundle's MANIFEST.MF
---
Eclipse-BundleShape: dir
---
Courtesy of the resolution of this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=157562
This circumvents my problem, and allows me to use gemini for persistence. I am happy.
If you require any more information, or clarifications feel free to ask.
Thanks all.
D.
* I can determine that the contents of the jar'd bundle can be read, because when the various GEMINI_DEBUG flags are on, I was able to see the contents of persistence.xml printed out. This could perhaps be the bundle being prompted to reading from itself. The problem occurs when one of the jpa bundles attempts to access resourced from my jar'd persistence bundles.
|
|
|
|
|
|
|
|
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #1810240 is a reply to message #764682] |
Mon, 05 August 2019 19:30 |
Margaret Woo Messages: 1 Registered: August 2019 |
Junior Member |
|
|
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.05012 seconds