Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How about a simple RCP and Hibernate example?
How about a simple RCP and Hibernate example? [message #436768] Sat, 17 September 2005 23:27 Go to next message
Jeremy is currently offline JeremyFriend
Messages: 12
Registered: July 2009
Junior Member
It seems everyone struggles with this at first. I have went through and
tried many solutions found here on the newsgroup with no luck. I've
gotten as far as getting my plugin to recognize my other hibernate
plugin, but it's unable to find the persistence.xml file needed by
Hibernate Entity Manager.

Anyone who has this working willing to make a simple HelloHibernateRCP
example for the rest of us to see?

Thanks,

Jeremy
Re: How about a simple RCP and Hibernate example? [message #436769 is a reply to message #436768] Sun, 18 September 2005 04:09 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
if you use eclipse 3.1 see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=87775
Jeremy wrote:

> It seems everyone struggles with this at first. I have went through and
> tried many solutions found here on the newsgroup with no luck. I've
> gotten as far as getting my plugin to recognize my other hibernate
> plugin, but it's unable to find the persistence.xml file needed by
> Hibernate Entity Manager.
>
> Anyone who has this working willing to make a simple HelloHibernateRCP
> example for the rest of us to see?
>
> Thanks,
>
> Jeremy
Re: How about a simple RCP and Hibernate example? [message #436771 is a reply to message #436769] Sun, 18 September 2005 12:47 Go to previous messageGo to next message
Jeremy is currently offline JeremyFriend
Messages: 12
Registered: July 2009
Junior Member
That seems to be nothing more than a contained collection of what I
already found on the newsgroups/websites.

How hard would it actually be for a sample RCP app that uses hibernate?
Say with 1 view that has a table viewer viewing people out of a database
with Name,Phone and clicking an Add button would Add a new hardcoded
person named "Person 1", "111-111-1111", "Person 2", "222-222-2222", etc...

I'd create one and put it on my website myself if I could figure out how
to make it work.

One difference in my application and others I have found are that I am
using Hibernate 3.1 along with Annotations and Entity Manager. My
problem comes down to not finding persistence.xml which is usually
located in the META-INF directory of a stand alone program:

META-INF/MANIFEST.MF
META-INF/persistence.xml
libs/hibernate-*.jar
libs/other-jars.jar
myapp.jar
run.bat

Jeremy

snpe wrote:
> if you use eclipse 3.1 see
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=87775
Re: How about a simple RCP and Hibernate example? [message #436772 is a reply to message #436771] Sun, 18 September 2005 15:22 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
Jeremy wrote:

> That seems to be nothing more than a contained collection of what I
> already found on the newsgroups/websites.
>
> How hard would it actually be for a sample RCP app that uses hibernate?
> Say with 1 view that has a table viewer viewing people out of a database
> with Name,Phone and clicking an Add button would Add a new hardcoded
> person named "Person 1", "111-111-1111", "Person 2", "222-222-2222",
> etc...
>
> I'd create one and put it on my website myself if I could figure out how
> to make it work.
>
> One difference in my application and others I have found are that I am
> using Hibernate 3.1 along with Annotations and Entity Manager. My
> problem comes down to not finding persistence.xml which is usually
> located in the META-INF directory of a stand alone program:
>
> META-INF/MANIFEST.MF
> META-INF/persistence.xml
> libs/hibernate-*.jar
> libs/other-jars.jar
> myapp.jar
> run.bat
>
Jeremy,
Where is your META-INF ?
If it is rcp plugin then user buddy classloader - you see
http://forum.hibernate.org/viewtopic.php?t=944666

if META-INF out of rcp plugins, then you search build classloader
in hibernate-tools project or wst rdb project

regards
Re: How about a simple RCP and Hibernate example? [message #436860 is a reply to message #436768] Mon, 19 September 2005 02:20 Go to previous messageGo to next message
John J. Franey is currently offline John J. FraneyFriend
Messages: 55
Registered: July 2009
Member
I've been trying to find an example and to write one. I have no success, but I got entity manager to find persistence.xml.

Maybe our approaches are similar: I build a jar plugin from Hibernate entitymanager and Hibernate annotations. A second plugin depends on the hib em/anno plugin and contains annotated model classes. A third plugin is the ui plugin and has a jface view whose content provider is trying to get an EntityManagerFactory.

My view calls javax.persistence.EntityManager.createEntityManagerFactory which requires META-INF/services/javax.persistence.spi.PersistenceProvider . This file contains the name of hibernates peristence provider class. Hibernate's persistence provider class needs META-INF/persistence.xml.

If neither of these two resources are in my ui plugin (the top plugin), I get an exception. They have to be in top plugin due to eclipse classloading scheme and hibernate's use of context loader. The javax.persistence.spi.PersistenceProvider resource is originally in entitymanager's distributed jar file in my base em/anno plugin. The persistence.xml resource is originally in my model plugin. These seem to be the logical places for them, but they are not found. There is much to this I do not understand but am looking for explanation. Can anyone help? I don't think the buddy classpath or the ContextFinder (discussed in the buzilla reference) addresses this issue.

But there is a third problem that I don't have a workaround yet. eclipse uses a URL protocol 'bundleresource' which is unexpected by entitymanager's jar visitor. See this hibernate EJB forum posting: http://forum.hibernate.org/viewtopic.php?t=947762.

Could someone here at eclipse point the way towards what 'bundlereource' url protocol means?

Thanks,
John
Re: How about a simple RCP and Hibernate example? [message #436871 is a reply to message #436772] Mon, 19 September 2005 14:10 Go to previous messageGo to next message
Jeremy is currently offline JeremyFriend
Messages: 12
Registered: July 2009
Junior Member
>>META-INF/MANIFEST.MF
>>META-INF/persistence.xml
>>libs/hibernate-*.jar
>>libs/other-jars.jar
>>myapp.jar
>>run.bat
>>
>
> Jeremy,
> Where is your META-INF ?
> If it is rcp plugin then user buddy classloader - you see
> http://forum.hibernate.org/viewtopic.php?t=944666
>
> if META-INF out of rcp plugins, then you search build classloader
> in hibernate-tools project or wst rdb project
>
> regards

The above example was for my stand alone, SWT version of the
application. I have tried placing META-INF in my src directory of the
plugin w/no luck.

Jeremy
Re: How about a simple RCP and Hibernate example? [message #436872 is a reply to message #436860] Mon, 19 September 2005 14:13 Go to previous messageGo to next message
Jeremy is currently offline JeremyFriend
Messages: 12
Registered: July 2009
Junior Member
John J. Franey wrote:

> My view calls javax.persistence.EntityManager.createEntityManagerFactory which requires META-INF/services/javax.persistence.spi.PersistenceProvider . This file contains the name of hibernates peristence provider class. Hibernate's persistence provider class needs META-INF/persistence.xml.

What is in META-INF/services/javax.persistence.spi.PersistenceProvider ?

So if I understand you correctly, you have META-INF/persistence.xml and
then the above file? What is the content of the above file?

Jeremy
Re: How about a simple RCP and Hibernate example? [message #436877 is a reply to message #436872] Mon, 19 September 2005 16:26 Go to previous messageGo to next message
John J. Franey is currently offline John J. FraneyFriend
Messages: 55
Registered: July 2009
Member
META-INF/services/javax.persistence.spi.PersistenceProvider is a file in hibernate-entitymanager.jar. It contains the class name of hibernate's persistence provider. You can extract it out of hibernate-entitymanager.jar using 'jar xf ...' (see help for jar command).

I have both this file and META-INF/persistence.xml in the classpath of my topmost plugin.

John
Re: How about a simple RCP and Hibernate example? [message #436885 is a reply to message #436877] Mon, 19 September 2005 20:28 Go to previous messageGo to next message
Jeremy is currently offline JeremyFriend
Messages: 12
Registered: July 2009
Junior Member
John J. Franey wrote:
> META-INF/services/javax.persistence.spi.PersistenceProvider is a file in hibernate-entitymanager.jar. It contains the class name of hibernate's persistence provider. You can extract it out of hibernate-entitymanager.jar using 'jar xf ...' (see help for jar command).
>
> I have both this file and META-INF/persistence.xml in the classpath of my topmost plugin.

I have done as you said but continue to suffer from:

Caused by: javax.persistence.PersistenceException: No Persistence
provider for EntityManager named smarten

Can you post your MANIFEST.MF file for the hibernate plugin?

Thanks!

Jeremy
Re: How about a simple RCP and Hibernate example? [message #436916 is a reply to message #436871] Tue, 20 September 2005 05:35 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
Jeremy wrote:

>
>>>META-INF/MANIFEST.MF
>>>META-INF/persistence.xml
>>>libs/hibernate-*.jar
>>>libs/other-jars.jar
>>>myapp.jar
>>>run.bat
>>>
>>
>> Jeremy,
>> Where is your META-INF ?
>> If it is rcp plugin then user buddy classloader - you see
>> http://forum.hibernate.org/viewtopic.php?t=944666
>>
>> if META-INF out of rcp plugins, then you search build classloader
>> in hibernate-tools project or wst rdb project
>>
>> regards
>
> The above example was for my stand alone, SWT version of the
> application. I have tried placing META-INF in my src directory of the
> plugin w/no luck.
>
> Jeremy
Do you have hibernate libs and persistence.xml in same plugins ?
Re: How about a simple RCP and Hibernate example? [message #437011 is a reply to message #436885] Tue, 20 September 2005 12:49 Go to previous message
John J. Franey is currently offline John J. FraneyFriend
Messages: 55
Registered: July 2009
Member
I'm attaching the manifest.mf for my home-constructed hibernate "EJB3" plugin. As I said, it contains entitymanager and annotations.

May I suggest you use eclipse debugger to single step through your apps call for an EntityManagerFactory? Obtain the hibernate entitymanager source code from hibernate.org before you start so that when Eclipse asks for source directory of javax.persistence.* and org.hibernate.ejb.* you can provide it.
Previous Topic:browser in a viewpart
Next Topic:create MenuItem within another MenuItem like a pullDown menu
Goto Forum:
  


Current Time: Fri Dec 27 03:03:48 GMT 2024

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

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

Back to the top