Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » During createEntityManagerFactory "Malformed (null) URL" Hides True Exception(While running gemini-jpa on a deployed equinox product, issues with createEntityManagerFactory. An URL is required, but it isn't clear which one is missing.)
During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #758848] Thu, 24 November 2011 17:39 Go to next message
Eclipse UserFriend
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 #758861 is a reply to message #758848] Thu, 24 November 2011 19:41 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Darren,

This was something that we saw during development at one point and was fixed. Did you go to a different version of the JDK or the JRE? I have entered a bug so that we can track what the issue might be. Please comment in the bug with any details that you may have that could be relevant.

Thanks,

-Mike
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #758869 is a reply to message #758861] Thu, 24 November 2011 20:56 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
BTW, where is the persistence.xml file placed in the bundle (META-INF/persistence.xml ?) and what is the Meta-Persistence manifest entry value?
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #758878 is a reply to message #758869] Thu, 24 November 2011 22:13 Go to previous messageGo to next message
Eclipse UserFriend
I've posted the answers to the bug entry.
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #759056 is a reply to message #758878] Fri, 25 November 2011 20:57 Go to previous messageGo to next message
Eclipse UserFriend
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 #759060 is a reply to message #759056] Fri, 25 November 2011 21:09 Go to previous messageGo to next message
Eclipse UserFriend
Also, in my case the Eclipse-IDE run version is using a URLArchive to access the persistence information, which is much more cooperative than my deployed version which is using a JarInputStreamURLArchive.
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #759063 is a reply to message #759060] Fri, 25 November 2011 21:27 Go to previous messageGo to next message
Eclipse UserFriend
Note:
My deployed build will work if I manually extract the persistent bundles from jar form to directory form. If I can get my Product Export build to produce the persistence bundles in directory form, I have an easy work-around.
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #759072 is a reply to message #759063] Fri, 25 November 2011 22:35 Go to previous messageGo to next message
Eclipse UserFriend
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 #759401 is a reply to message #759072] Mon, 28 November 2011 14:57 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Thanks for all your input on this issue, Darren.

-Mike
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #763300 is a reply to message #758848] Fri, 09 December 2011 14:34 Go to previous messageGo to next message
Nepomuk Seiler is currently offline Nepomuk SeilerFriend
Messages: 88
Registered: December 2010
Member
Hi,

I have the same issue. I recognized it after upgrading
to Java 7.

cheers,
Muki
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #764664 is a reply to message #763300] Mon, 12 December 2011 16:08 Go to previous messageGo to next message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Muki, can you please add any details from your situation to the bug?

Thanks,
-Mike
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #764668 is a reply to message #764664] Mon, 12 December 2011 16:18 Go to previous messageGo to next message
Eclipse UserFriend
Note:
When I experienced this issue, I was also using a Java 7 jre.
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #764682 is a reply to message #764668] Mon, 12 December 2011 16:58 Go to previous messageGo to next message
Nepomuk Seiler is currently offline Nepomuk SeilerFriend
Messages: 88
Registered: December 2010
Member
Hi Mike,

My application is based on:


  • Eclipse 3.7.1
  • Gemini JPA 1.0.0.RELEASE
  • Gemini DBAccess 1.0.0.RELEASE
  • Eclipse RCP Application
  • BUNDLES_REFRESH=false
  • Derby 10.5.1.1


I have no problems running this in the IDE like Darren.
However after my first deployment after a longer time
where only the JDK changed this errors occured.
Re: During createEntityManagerFactory "Malformed (null) URL" Hides True Exception [message #1810240 is a reply to message #764682] Mon, 05 August 2019 19:30 Go to previous message
Margaret Woo is currently offline Margaret WooFriend
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.
Previous Topic:Does Gemini Blueprint support JSR 250 annotations?
Next Topic:OSGI extender error
Goto Forum:
  


Current Time: Fri Nov 08 23:00:37 GMT 2024

Powered by FUDForum. Page generated in 0.04523 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top