Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] JPA not working inside Equinox but fine in unit tests

Hi Caspar,
   
    Well, there's lots going on here so let me throw out some advice/comments for you consider.  First, in OSGi you need to explicitly set weaving=true if you want it to work.  By default weaving will default to off in OSGi.  And when you turn weaving on you need to deploy the two fragments that implement Equinox weaving: org.eclipse.persistence.jpa.equionox and org.eclipse.persistence.jpa.equionox.weaving.   And you need to install the Equinox fragment with  -Dosgi.framework.extensions=org.eclipse.persistence.jpa.equinox.weaving

    I'm not familiar with PAX Runner so how are you launching Equinox?  Do you have a config.ini file?  The weaving fragment uses the Equinox AdaptorHook framework and I found that if not launched correctly (one example is described here: http://wiki.eclipse.org/EclipseLink/Examples/OSGi/Equinox_Byte_Code_Weaving) the weaving fragment, while attached to its host, was not hooked into the classloading infrastructure.  It works fine in PDE because of how it launches Equinox.

    To debug this I'd recommend starting with the instructions on the wiki but substitute in your domain class bundle.  Just see if you can get an EntityManagerFactory with this minimal configuration.

    Shaun


   

On 6/5/2010 8:27 AM, Caspar MacRae wrote:

Hi,

Further to my previous post - Dali helped clear a few issues, but unfortunately the problems still persist =(      (intentional bad pun)


When weaving is set to false the unit tests run fine, but in Equinox I still see:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.1.0.v20100311-r6779): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: org.eclipse.persistence.internal.jpa.deployment.osgi.CompositeClassLoader@6c91f005
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.1.0.v20100311-r6779): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [crm] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.1.0.v20100311-r6779): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class com.matterhorn.crm.domain.person.Person] uses a non-entity [class com.matterhorn.crm.domain.interaction.Interaction] as target entity in the relationship attribute [field interactions].
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:133)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:65)
at com.matterhorn.crm.dao.internal.DaoActivationModule.getEntityManagerFactory(DaoActivationModule.java:66)
at com.matterhorn.crm.dao.internal.DaoActivationModule$1.createEntityManagerFactory(DaoActivationModule.java:39)
at com.matterhorn.crm.dao.internal.GuiceModule.getEntityManagerFactory(GuiceModule.java:57)
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 com.google.inject.internal.ProviderMethod.get(ProviderMethod.java:101)
at com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
at com.google.inject.SingleParameterInjector.inject(SingleParameterInjector.java:43)
at com.google.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:64)
at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:93)
at com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:110)
at com.google.inject.InjectorImpl$4$1.call(InjectorImpl.java:759)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:813)
at com.google.inject.InjectorImpl$4.get(InjectorImpl.java:755)
at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:790)
at org.ops4j.peaberry.internal.Setting$2.get(Setting.java:79)
at org.ops4j.peaberry.internal.ServiceSettings.getExport(ServiceSettings.java:180)
at org.ops4j.peaberry.internal.ExportedServiceProvider.get(ExportedServiceProvider.java:45)
at org.ops4j.peaberry.internal.ExportedServiceProvider.get(ExportedServiceProvider.java:31)
at com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
at com.google.inject.InjectorImpl$4$1.call(InjectorImpl.java:759)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:805)
at com.google.inject.InjectorImpl$4.get(InjectorImpl.java:755)
at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:790)
at org.ops4j.peaberry.activation.internal.InstanceBundleRoot.activate(InstanceBundleRoot.java:45)
at org.ops4j.peaberry.activation.internal.BundleActivation.activate(BundleActivation.java:178)
at org.ops4j.peaberry.activation.internal.BundleActivation.update(BundleActivation.java:156)
at org.ops4j.peaberry.activation.internal.StateBundleActivationTracker.start(StateBundleActivationTracker.java:38)
at org.ops4j.peaberry.activation.internal.BundleActivation.start(BundleActivation.java:136)
at org.ops4j.peaberry.activation.internal.BundleTracker.start(BundleTracker.java:103)
at org.ops4j.peaberry.activation.internal.BundleTracker.bundleChanged(BundleTracker.java:82)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:919)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1350)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1301)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:362)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.1.0.v20100311-r6779): org.eclipse.persistence.exceptions.EntityManagerSetupException

The order of exceptions changes with each run, but is always reported on a many-to-many relationship, the mapping of this one is specified as:

@OrderBy("date")
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Interaction.class)
@JoinTable(name = "interaction_person", joinColumns = { @JoinColumn(name = "people") }, inverseJoinColumns = { @JoinColumn(name = "interactions") } )
private List<Interaction> interactions;

and on another (exception is identical apart from class references):

@ManyToMany(targetEntity = OutlookInvitationEmail.class, fetch = FetchType.LAZY)
@JoinTable(name = "staff_invitations", joinColumns = { @JoinColumn(name = "recipients") }, 
inverseJoinColumns = { @JoinColumn(name = "invitations") } )
private List<OutlookInvitationEmail> invitations;




With weaving set to dynamic, for Unit tests, I get:


java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.preInitialize(ForeignReferenceMapping.java:852)
at org.eclipse.persistence.mappings.ObjectReferenceMapping.preInitialize(ObjectReferenceMapping.java:921)
at org.eclipse.persistence.descriptors.ClassDescriptor.preInitialize(ClassDescriptor.java:3331)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:429)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:230)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:371)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:157)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:214)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:202)
at com.matterhorn.crm.dao.internal.GenericDaoImp$1.initialValue(GenericDaoImp.java:39)
at com.matterhorn.crm.dao.internal.GenericDaoImp$1.initialValue(GenericDaoImp.java:37)
at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:141)
at java.lang.ThreadLocal.get(ThreadLocal.java:131)
at com.matterhorn.crm.dao.internal.GenericDaoImp$1.get(GenericDaoImp.java:43)
at com.matterhorn.crm.dao.internal.GenericDaoImp$1.get(GenericDaoImp.java:37)
at com.matterhorn.crm.dao.internal.GenericDaoImp.getEntityManager(GenericDaoImp.java:69)
at com.matterhorn.crm.dao.internal.GenericDaoImp.count(GenericDaoImp.java:265)
at com.matterhorn.crm.dao.client.ClientDaosTest.setUp(ClientDaosTest.java:52)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.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:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)

So looking at ForeignReferenceMapping.java:852 I set weaving.lazy set to false and instead got:

java.lang.NullPointerException
at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getMethodReturnType(PrivilegedAccessHelper.java:302)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getGetMethodReturnType(MethodAttributeAccessor.java:105)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.validateBeforeInitialization(ForeignReferenceMapping.java:1553)
at org.eclipse.persistence.descriptors.ClassDescriptor.validateBeforeInitialization(ClassDescriptor.java:5269)
at org.eclipse.persistence.descriptors.ClassDescriptor.preInitialize(ClassDescriptor.java:3337)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:429)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:230)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:371)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:157)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:214)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:202)
at com.matterhorn.crm.dao.internal.GenericDaoImp$1.initialValue(GenericDaoImp.java:39)
at com.matterhorn.crm.dao.internal.GenericDaoImp$1.initialValue(GenericDaoImp.java:37)
at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:141)
at java.lang.ThreadLocal.get(ThreadLocal.java:131)
at com.matterhorn.crm.dao.internal.GenericDaoImp$1.get(GenericDaoImp.java:43)
at com.matterhorn.crm.dao.internal.GenericDaoImp$1.get(GenericDaoImp.java:37)
at com.matterhorn.crm.dao.internal.GenericDaoImp.getEntityManager(GenericDaoImp.java:69)
at com.matterhorn.crm.dao.internal.GenericDaoImp.count(GenericDaoImp.java:265)
at com.matterhorn.crm.dao.client.ClientDaosTest.setUp(ClientDaosTest.java:52)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.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:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)

and this for virtually every entity:

Exception [EclipseLink-1] (Eclipse Persistence Services - 2.1.0.v20100311-r6779): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The attribute [investmentProcess] is not declared as type ValueHolderInterface, but its mapping uses indirection.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[investmentProcess]
Descriptor: RelationalDescriptor(com.matterhorn.crm.domain.client.Client --> [DatabaseTable(client)])



After cleaning up the mappings with the warnings/issues provided by Dali, I am stuck as to how to progress in identifying the underlying issue, any advice would be most gratefully received.

thanks,
Caspar

_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

--
Oracle
Shaun Smith | Principal Product Manager
Phone: +19055023094
Oracle Server Technologies, Oracle TopLink
ORACLE Canada | 110 Matheson Boulevard West, Suite 100, Mississauga, Ontario | L5R 3P4

Green Oracle Oracle is committed to developing practices and products that help protect the environment

Back to the top