Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » RCP with JPA
RCP with JPA [message #489756] Mon, 05 October 2009 15:19 Go to next message
Bill is currently offline Bill
Messages: 3
Registered: October 2009
Junior Member
I'm having a really hard time getting an Eclipse RCP application working with java persistence.
I initially created a JPA project called Data. I have one managed class, MyData, from an Oracle database.
I then converted it to a plugin project.
Next I created a new Plug-in project using the wizard. I checked generate an activator....., ....will make contributions to the UI and selected yes to create RCP app.
I added my JPA project, Data, to the plugin dependencies of my RCP app.
In my RCP app i created a new Visual Class using RCP>View as the style. In this class I have a button that selects data from the class in my JPA project. Everything seems to work well. I am able to write the contents of the table to the console.
Next I created an extension to my RCP view. I added it to the views and perspectiveExtensions.
When I run the RCP project and click the button to retrieve the data from my class in the JPA project i get the follwoing error...
!ENTRY org.eclipse.ui 4 0 2009-10-05 14:47:19.562
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NoClassDefFoundError: javax/persistence/Persistence
	at mtmpui.Members$1.widgetSelected(Members.java:44)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at mtmpui.Application.start(Application.java:20)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Persistence
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	... 27 more


I've added all the EclipseLink jars from my JPA project to my RCP buildpath...
javax.persistence_1.99.0.v200906021518.jar
org.eclipse.persistence.antlr_1.1.2.v20090612-r4475.jar
org.eclipse.persistence.asm_1.1.2.v20090612-r4475.jar
org.eclipse.persistence.core_1.1.2.v20090612-r4475.jar
org.eclipse.persistence.jpa_1.1.2.v20090612-r4475.jar

I've been working at this for almost a week and I don't know what to try next. I've tried searching the web and the only thing I found said that you need to separate the data into a JPA plugin project and add it as a plugin dependency in the RCP app.

Re: RCP with JPA [message #489925 is a reply to message #489756] Tue, 06 October 2009 10:06 Go to previous messageGo to next message
Bill is currently offline Bill
Messages: 3
Registered: October 2009
Junior Member
I took the 5 jar files and created a new Plugin project from existing jar files with them. I then added this project as a dependecny in my RCP project.
Now I get the following error message...
!ENTRY org.eclipse.ui 4 0 2009-10-06 09:58:50.102
!MESSAGE Unhandled event loop exception
!STACK 0
javax.persistence.PersistenceException: No Persistence provider for EntityManager named test
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at mtmpui.Members$1.widgetSelected(Members.java:42)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at mtmpui.Application.start(Application.java:20)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)



I'm sure this is a reference issue but I've tried adding references to these 5 files in every place imaginable.

My persistence.xml file looks like this...
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
	<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
		<class>my.Class</class>
		<properties>
			<property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@mydb:123:sid" />
			<property name="eclipselink.jdbc.user" value="user" />
			<property name="eclipselink.jdbc.password" value="passwd" />
			<property name="eclipselink.jdbc.driver" value="oracle.jdbc.OracleDriver" />
		</properties>
	</persistence-unit>
</persistence>


If I run my rcp view standalone as a javabean it works fine. I only have an issue running inside the rcp app.
Re: RCP with JPA [message #489937 is a reply to message #489925] Tue, 06 October 2009 10:34 Go to previous messageGo to next message
Thomas SZADEL is currently offline Thomas SZADEL
Messages: 36
Registered: July 2009
Member
Hi!

Humm... another idea: did you try the buddy class loading? It allows a "reverse" dependency (that's to say when A depends on B, you want B to have visibility on A).

In your persistence plugin, add (in your MANIFEST.MF):
Eclipse-BuddyPolicy: registered


In the plugin where you store your persistence.xml (in your MANIFEST.MF):
Eclipse-RegisterBuddy: <persistence plugin id>


Tom
icon4.gif  Re: RCP with JPA [message #490003 is a reply to message #489756] Tue, 06 October 2009 16:18 Go to previous messageGo to next message
alan kemp is currently offline alan kemp
Messages: 17
Registered: October 2009
Junior Member
glad I saw your post. i too am having troubles integrating eclipse link JPA into a rich client eclipse plugin. i also posted to the eclipse link forum. and yes i am getting the same thing: No Persistence provider for EntityManager named XXXX. have you had any more success with this?
icon5.gif  Re: RCP with JPA [message #492526 is a reply to message #489756] Tue, 20 October 2009 12:08 Go to previous messageGo to next message
alan kemp is currently offline alan kemp
Messages: 17
Registered: October 2009
Junior Member
somebody?? anybody?? any ideas??
Re: RCP with JPA [message #492711 is a reply to message #489756] Wed, 21 October 2009 09:43 Go to previous messageGo to next message
Bill is currently offline Bill
Messages: 3
Registered: October 2009
Junior Member
So, in my plugin project, which stores my persistence objects, I added the following to MANIFEST.MF...
Eclipse-BuddyPolicy: registered

In my RCP application I added the following to MANIFEST.MF...
Eclipse-RegisterBuddy: <PluginProjectName>

Still doesn't work and I get the same error.
My RCP Application does not contain a persistence.xml file. Is that ok? The persistence.xml file is stored in my plugin project which contains my persistence objects.
Re: RCP with JPA [message #494269 is a reply to message #492711] Thu, 29 October 2009 17:02 Go to previous message
Oliver Vesper is currently offline Oliver Vesper
Messages: 42
Registered: July 2009
Member
Hey Bill!

> So, in my plugin project, which stores my persistence objects, I added
> the following to MANIFEST.MF...
> Eclipse-BuddyPolicy: registered
> In my RCP application I added the following to MANIFEST.MF...
> Eclipse-RegisterBuddy: <PluginProjectName>
> Still doesn't work and I get the same error.

I recommend having a look at
http://wiki.eclipse.org/EclipseLink/Examples/OSGi/Developing _with_EclipseLink_OSGi_in_PDE.
I've got my rcp applications work well using EclipseLink and without
making use of the buddy-mechanism.

> My RCP Application does not contain a persistence.xml file. Is that ok?
> The persistence.xml file is stored in my plugin project which contains
> my persistence objects.

That should be okay...

HTH,
Oliver
Previous Topic:Developer/isv documentation in target platform
Next Topic:How to invoke a handler with a progress monitor?
Goto Forum:
  


Current Time: Thu Aug 28 23:30:18 EDT 2014

Powered by FUDForum. Page generated in 0.02609 seconds