Student(Entity class)オブジェクトを永続化するために、JPA2.0をサポートする小さなOSGIブルドルプロジェクトを作成しました。
このサービスを正常に開始できます。
このサービスにアクセスするための別のクライアントバンドルプロジェクトを作成しました。クライアントブルドルサービスを開始しようとすると、次のエラーが発生します
原因:javax.persistence.PersistenceException:StudentJPAServiceという名前のEntityManagerの永続性プロバイダーがありません
以下の完全なスタックトレースを見つけてください
!ENTRY StudentJPAClient 4 0 2013-03-04 14:17:21.846
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Exception in student.jpaclient.Activator.start() of bundle StudentJPAClient.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.ExceptionInInitializerError
at com.student.jpaservice.serviceimpl.StudentDAOService.persist(StudentDAOService.java:16)
at student.jpaclient.Activator.start(Activator.java:30)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 12 more
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named StudentJPAService
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.student.jpaservice.util.StudentUtil.<clinit>(StudentUtil.java:11)
... 17 more
Root exception:
java.lang.ExceptionInInitializerError
at com.student.jpaservice.serviceimpl.StudentDAOService.persist(StudentDAOService.java:16)
at student.jpaclient.Activator.start(Activator.java:30)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named StudentJPAService
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.student.jpaservice.util.StudentUtil.<clinit>(StudentUtil.java:11)
... 17 more
MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: StudentJPAService
Bundle-SymbolicName: StudentJPAService;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.student.jpaservice.actovator.Activator
Import-Package: javax.persistence;version="1.1.0",
org.osgi.framework
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.student.jpaservice.actovator,
com.student.jpaservice.model,
com.student.jpaservice.service,
com.student.jpaservice.serviceimpl,
com.student.jpaservice.util
Bundle-ActivationPolicy: lazy
Meta-Persistence: META-INF/persistence.xml
Bundle-ClassPath: ../lib/j2ee.jar,
../lib/javax.j2ee.persistence.jar,
../lib/mysql-connector-java-5.1.7-bin.jar,
.
JPA-PersistenceUnits: StudentJPAService
以下の投稿でも同じ問題が見られますが、問題を解決するのに役立ちませんでした。
OSGi + JPA(postgresql)
この問題の解決にご協力ください。