Hi
I've been trying to use the TopLink essentials JPA implementation in an
Eclipse Rich Client Platform application but I get the exception below
when I try and create an EntityManagerFactory.
It seems that this is because the Eclipse plug-in environment
classloaders create URLs of the following form:
bundleresource://3/META-INF/persistence.xml
For example the above URL would be returned by a call to:
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Enumeration<URL> resources =
loader.getResources("META-INF/persistence.xml");
There is code in PersistenceUnitProcessor that is using the context
class loader in this way to find resources for the persistence units and
this fails with the exception below because it is seems like it is only
expecting URLs with a file or jar protocol.
[Out of interest the Hibernate JPA implementation seems to handle this okay]
Would you consider this a bug, or is it possible I'm doing something wrong?
Thanks
Martin
Exception:
java.lang.NullPointerException
at
oracle.toplink.essentials.ejb.cmp3.persistence.ArchiveFactoryImpl.createArchive(ArchiveFactoryImpl.java:64)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:207)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:190)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:239)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initializeFromMain(JavaSECMPInitializer.java:278)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.getJavaSECMPInitializer(JavaSECMPInitializer.java:81)
at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:118)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at
testjpaplugintoplink.View$ViewContentProvider.getElements(View.java:77)
at
org.eclipse.jface.viewers.StructuredViewer.getRawChildren(StructuredViewer.java:927)
at
org.eclipse.jface.viewers.TableViewer.getRawChildren(TableViewer.java:1279)
at
org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:868)
at
org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:984)
at
org.eclipse.jface.viewers.TableViewer.internalRefreshAll(TableViewer.java:870)
at
org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:818)
at
org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:807)
at
org.eclipse.jface.viewers.StructuredViewer$7.run(StructuredViewer.java:1388)
at
org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1323)
at
org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1386)
at
org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1345)
at
org.eclipse.jface.viewers.TableViewer.inputChanged(TableViewer.java:767)
at
org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:250)
at
org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1542)
at testjpaplugintoplink.View.createPartControl(View.java:189)
at
org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:332)
at
org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:197)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:566)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:290)
at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:525)
at
org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:140)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:268)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:394)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1144)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1097)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1311)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:601)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:532)
at
org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:562)
at
org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:244)
at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:815)
at
org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2429)
at
org.eclipse.ui.internal.WorkbenchWindow$6.run(WorkbenchWindow.java:2616)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at
org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2597)
at
org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:658)
at
org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow(Workbench.java:795)
at
org.eclipse.ui.internal.Workbench.doOpenFirstTimeWindow(Workbench.java:1437)
at
org.eclipse.ui.internal.Workbench.openFirstTimeWindow(Workbench.java:1388)
at
org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow(WorkbenchConfigurer.java:190)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:708)
at org.eclipse.ui.internal.Workbench.init(Workbench.java:1085)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1847)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at testjpaplugintoplink.Application.run(Application.java:18)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)