Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » How to use Hibernate/JPA with OSGi
How to use Hibernate/JPA with OSGi [message #104918] Mon, 11 February 2008 07:51 Go to next message
Eclipse UserFriend
Originally posted by: madihaanees.hotmail.com

Hello fellows.

I am developing one application which requires persistence with database
so I am using hibernate / JPA (EJB3-JBoss).

My structure of the of the osgi bundles are as follows

plug-in 1) "my.mimos.ejb3.hibernate.plugin" has hibernate-3,
ejb3-persistence, ejb3.x and ejb3 jar files
in its MANIFEST.MF "Eclipse-BuddyPolicy: registered" is added

plun-in 2) is my jpa bundle where i want to register EntityManagerFactory
let say "my.xxx.bundles.jpabundle" in its MANIFEST.MF
"Eclipse-RegisterBuddy: my.mimos.ejb3.hibernate.plugin" is added

jpa jar ) this is my ejb project which has entity beans and
persistence.xml file in its META-INF folder. and is packed in jar file
.... let us say liberary.jar

and liberary.jar file is added into the classpath of plug-in-2 and
exported its package let us say "my.mimos.bundles.databaseservice.beans".

plug-in 3) "my.mimos.bundles.databaseservice" is my database service used
for injection and usage of entity manager of hibernate/jpa. in its
MANFEST.MF file i didn't added the buddy policy of eclipse. this plug-in
use the jpa plug and pass the peristence unit name to the jpa bundle to
create the "EntityManagerFactory"

but when i run these plug-ins i got the following error. I am posting all
console message.

WARNING: Unable to find file (ignored): bundleresource://142
java.io.FileNotFoundException:
C:\Testing\eclipse-SDK-3.2.2-win32\projects\my.xxx.bundles.j pabundle\bin
(Access is denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at
org.eclipse.osgi.framework.util.SecureAction.getFileInputStr eam(SecureAction.java:98)
at
org.eclipse.osgi.baseadaptor.bundlefile.FileBundleEntry.getI nputStream(FileBundleEntry.java:50)
at
org.eclipse.osgi.framework.internal.core.BundleURLConnection .connect(BundleURLConnection.java:53)
at
org.eclipse.osgi.framework.internal.core.BundleURLConnection .getInputStream(BundleURLConnection.java:99)
at java.net.URL.openStream(Unknown Source)
at
org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doPr ocessElements(InputStreamZippedJarVisitor.java:33)
at
org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(Ja rVisitor.java:215)
at
org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(E jb3Configuration.java:253)
at
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configurat ion.java:229)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFa ctory(HibernatePersistence.java:120)
at
javax.persistence.Persistence.createEntityManagerFactory(Per sistence.java:51)
at
javax.persistence.Persistence.createEntityManagerFactory(Per sistence.java:33)
at
my.mimos.bundles.jpabundle.service.JPAServiceBean.createEnti tyManagerFactory(JPAServiceBean.java:31)
at
my.mimos.bundles.databaseservice.tracker.JPATracker.addingSe rvice(JPATracker.java:33)
at
org.osgi.util.tracker.ServiceTracker$Tracked.trackAdding(Ser viceTracker.java:1014)
at
org.osgi.util.tracker.ServiceTracker$Tracked.track(ServiceTr acker.java:992)
at
org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged( ServiceTracker.java:917)
at
org.eclipse.osgi.framework.internal.core.FilteredServiceList ener.serviceChanged(FilteredServiceListener.java:71)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.d ispatchEvent(BundleContextImpl.java:1216)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEve nt(EventManager.java:189)
at
org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEv entSynchronous(ListenerQueue.java:141)
at
org.eclipse.osgi.framework.internal.core.Framework.publishSe rviceEventPrivileged(Framework.java:1535)
at
org.eclipse.osgi.framework.internal.core.Framework.publishSe rviceEvent(Framework.java:1510)
at
org.eclipse.osgi.framework.internal.core.ServiceRegistration Impl. <init>(ServiceRegistrationImpl.java:103)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.c reateServiceRegistration(BundleContextImpl.java:649)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.r egisterService(BundleContextImpl.java:601)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.r egisterService(BundleContextImpl.java:667)
at my.mimos.bundles.jpabundle.Activator.start(Activator.java:29 )
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:991)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:985)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:966)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:317)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.resu me(AbstractBundle.java:329)
at
org.eclipse.osgi.framework.internal.core.Framework.resumeBun dle(Framework.java:1046)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.r esumeBundles(StartLevelManager.java:573)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.i ncFWSL(StartLevelManager.java:495)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.d oSetStartLevel(StartLevelManager.java:275)
at
org.eclipse.osgi.framework.internal.core.StartLevelManager.d ispatchEvent(StartLevelManager.java:455)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEve nt(EventManager.java:189)
at
org.eclipse.osgi.framework.eventmgr.EventManager$EventThread .run(EventManager.java:291)
Feb 11, 2008 3:48:39 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Feb 11, 2008 3:48:39 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Feb 11, 2008 3:48:39 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: true
Feb 11, 2008 3:48:39 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.postgresql.Driver at URL:
jdbc:postgresql://127.0.0.1/mimos
Feb 11, 2008 3:48:39 PM
org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=postgres, password=****,
autocommit=true, release_mode=auto}
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: PostgreSQL, version: 8.1.5
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.1 JDBC3
with SSL (build 407)
Feb 11, 2008 3:48:39 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.PostgreSQLDialect
Feb 11, 2008 3:48:39 PM
org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy:
org.hibernate.transaction.JDBCTransactionFactory
Feb 11, 2008 3:48:39 PM
org.hibernate.transaction.TransactionManagerLookupFactory
getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of
read-write or transactional second-level cache is not recommended)
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory
createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Feb 11, 2008 3:48:39 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory
<init>
INFO: Using ASTQueryTranslatorFactory
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: enabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory
createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Feb 11, 2008 3:48:39 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled

please do help me where i did something wrong and how can i able to solve
this issue. bcoz when i try to use the EntityManager created by this
EntityManagerFacotry.... it will not able to recognize the entity beans.

Regards,

ANees-ur-Rehman
Re: How to use Hibernate/JPA with OSGi [message #105089 is a reply to message #104918] Tue, 12 February 2008 17:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sd-silva.criticalsoftware.com

Hi,

My advice it's to try to use easybeans

http://wiki.easybeans.org/xwiki/bin/Main/OSGi

I'm using it, with no problems.
Re: How to use Hibernate/JPA with OSGi [message #105102 is a reply to message #105089] Wed, 13 February 2008 02:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: madihaanees.gmail.com

Thanks for your reply.

Actually I tried using EasyBeans. but one i deploy easy beans in equinox
they got installed. but when I try to start them I got errors like
javax.management error with version 1.5.0

can u help me how to solve this issue.

regards
Anees-ur-Rehman
Re: How to use Hibernate/JPA with OSGi [message #107678 is a reply to message #105102] Mon, 07 April 2008 18:30 Go to previous messageGo to next message
J. Ulbts is currently offline J. UlbtsFriend
Messages: 2
Registered: July 2009
Junior Member
I've a similar problem with Eclipse RCP (v3.3.x) and Hibernate 3.2.5 and Hibernate Annotations 3.3.0.GA.
The persistence.xml is loaded and seems to work.

I try to use EntityManagerFactory for JPA, and I think this is correct.
I was able to use the Hibernate SessionFactory with Annotations before but I need full JPA compatibility so I had to switch to the EntityManagerFactory which gives me this result.

Here are some details. If more information is needed let me know.

In my console output I get this:
[..]
19:39:23,156 DEBUG JarVisitor:218 - Searching mapped entities in jar/par: bundleresource://112
19:39:23,171  WARN InputStreamZippedJarVisitor:37 - Unable to find file (ignored): bundleresource://112
java.io.FileNotFoundException: D:\Daten\Java\Eclipse\workspace33X\MidArchRepo.DataModel\bin (Zugriff verweigert)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:106)
[..]


But the biggest problem is this at the log:
!ENTRY org.eclipse.osgi 4 0 2008-04-07 19:39:23.640
!MESSAGE An error occurred while automatically activating bundle midarchrepo.main (149).
!STACK 0
org.osgi.framework.BundleException: Exception in midarchrepo.main.Activator.start() of bundle midarchrepo.main.
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1018)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260)
	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:400)
	at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:111)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:417)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:189)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:340)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:408)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:369)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:357)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.loadClass(BundleLoader.java:289)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:227)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1269)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:160)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:788)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:165)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
	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.equinox.launcher.Main.invokeFramework(Main.java:508)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
Caused by: java.lang.LinkageError: Class javax/management/MBeanServer violates loader constraints
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:161)
[..]
Re: How to use Hibernate/JPA with OSGi [message #107718 is a reply to message #107678] Tue, 08 April 2008 08:33 Go to previous messageGo to next message
J. Ulbts is currently offline J. UlbtsFriend
Messages: 2
Registered: July 2009
Junior Member
The LinkageError (MBeanServer) is caused by the combination of Eclipse v3.3 and Hibernate.
Eclipse v3.3 includes JMX and so does hibernate via 3rd party libraries. The library in Hibernate is JBoss or to be more specific jboss-jmx.jar.

If the jmx is removed from Hibernate is should work (not yet tested, but is does make sense).

See also this posting at the Eclipse Newsgroup (from 2007) describing the exact same problem:
http://dev.eclipse.org/newslists/news.eclipse.platform/msg65 467.html
Re: How to use Hibernate/JPA with OSGi [message #110797 is a reply to message #104918] Tue, 27 May 2008 20:33 Go to previous message
Eclipse UserFriend
Originally posted by: hans.loedolff.com

I have built an example that shows how to use Hibernate in OSGi. It uses Equinox, Spring DM, Maven and HSQLDB.

The project is hosted here: http://code.google.com/p/voluble/wiki/OsgiHibernateSpringSpr ingDMSample
Previous Topic:Using p2 to install a product
Next Topic:Running an empty equinox container without console port
Goto Forum:
  


Current Time: Sun Sep 22 23:10:44 GMT 2024

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

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

Back to the top