openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heather Sterling <vtpowerp...@gmail.com>
Subject need clarification on entity listener loading
Date Wed, 07 Oct 2009 18:11:08 GMT
Hi,

I am seeing some strange behavior where my entity listeners are being
instantiated by OpenJPA multiple times.  I first initialize things by dong
the following.  I added trace statments to the public no-arg constructor of
my entity listeners and I see that it's called six times, all stemming from
this one call (I'm only making the call once).

    protected void initializeMetadata(OpenJPAConfiguration conf) {
        String method = "initializeMetadata";
        logger.entering(CLASSNAME, method);

        //Get all PersistentClasses defined in persistence.xml
        Collection<Class> persistentClasses =
conf.getMetaDataRepositoryInstance().loadPersistentTypes(true, null);


Later on we have a case where one of our entity listeners executes a query
on the same calling thread.  This causes OpenJPA to again re-instantiate at
least one of our entity listeners.  Here is one of the call stacks.  There
are two entity listeners involved: JPACorrelator and
RelationshipEntityListener.  RelationshipEntityListener performs a query on
the calling thread and OpenJPA again calls the JPACorrelator constructor.
One additional note is that JPACorrelator acts as both an entity listener
and an OpenJPA TransactionListener.  JPACorrelator is listed before
RelationshipEntityListener in our root element.

@EntityListeners({ JPACorrelator.class, RelationshipEntityListener.class,
CascadingDeleteHandler.class, JPANotificationHandler.class,
DeletedResourceEntityListener.class })

I'm not sure what would cause this behavior -- I assumed OpenJPA would only
ever create the entity listeners once; if most of our data wasn't static, we
would be hitting quite a few problems at this point.  Can anyone tell me
what the correct behavior is and how I could have possibly gotten into this
situation?

Thanks


Call Stack:

com.ibm.sysmgmt.persistence.jpa.services.JPAServicesException: Constructor
init
at
com.ibm.sysmgmt.persistence.jpa.extensions.JPACorrelator.<init>(JPACorrelator.java:107)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1243)
at
org.apache.openjpa.lib.util.J2DoPrivHelper$11.run(J2DoPrivHelper.java:343)
at java.security.AccessController.doPrivileged(AccessController.java:242)
at
org.apache.openjpa.event.BeanLifecycleCallbacks.newListener(BeanLifecycleCallbacks.java:66)
at
org.apache.openjpa.event.BeanLifecycleCallbacks.<init>(BeanLifecycleCallbacks.java:61)
at
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseCallbackMethods(AnnotationPersistenceMetaDataParser.java:864)
at
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseEntityListeners(AnnotationPersistenceMetaDataParser.java:796)
at
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseClassAnnotations(AnnotationPersistenceMetaDataParser.java:515)
at
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parse(AnnotationPersistenceMetaDataParser.java:352)
at
org.apache.openjpa.persistence.PersistenceMetaDataFactory.load(PersistenceMetaDataFactory.java:229)
at
org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:474)
at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:294)
at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:363)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:159)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:139)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756)
at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56)
at
org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:153)
at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658)
at
org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639)
at
org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605)
at
org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667)
at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492)
at
org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243)
at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)
at
com.ibm.sysmgmt.persistence.jpa.extensions.EntityManagerConnectionManager.executeQuery(EntityManagerConnectionManager.java:628)
at
com.ibm.sysmgmt.persistence.jpa.extensions.EntityManagerConnectionManager.processQuery(EntityManagerConnectionManager.java:685)
at
com.ibm.sysmgmt.persistence.jpa.extensions.RelationshipEntityListener.removeRelInfos(RelationshipEntityListener.java:317)
at
com.ibm.sysmgmt.persistence.jpa.extensions.RelationshipEntityListener.updateRelationshipInfo(RelationshipEntityListener.java:291)
at
com.ibm.sysmgmt.persistence.jpa.extensions.RelationshipEntityListener.postUpdateMessage(RelationshipEntityListener.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at
org.apache.openjpa.event.BeanLifecycleCallbacks.makeCallback(BeanLifecycleCallbacks.java:85)
at
org.apache.openjpa.event.LifecycleEventManager.makeCallbacks(LifecycleEventManager.java:340)
at
org.apache.openjpa.event.LifecycleEventManager.fireEvent(LifecycleEventManager.java:302)
at
org.apache.openjpa.kernel.BrokerImpl.fireLifecycleEvent(BrokerImpl.java:688)
at
org.apache.openjpa.kernel.StateManagerImpl.fireLifecycleEvent(StateManagerImpl.java:352)
at
org.apache.openjpa.kernel.StateManagerImpl.afterFlush(StateManagerImpl.java:1008)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2033)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1350)
at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:877)
at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:512)
at
com.ibm.sysmgmt.persistence.jpa.extensions.EntityManagerConnectionManager.tryCommit(EntityManagerConnectionManager.java:358)
at
com.ibm.sysmgmt.resource.caching.jpa.test.JPADirectJPATest.testDirectJPA_ServerCreation(JPADirectJPATest.java:200)
at
com.ibm.sysmgmt.resource.caching.jpa.test.JPATestPlugin.runTestSuite(JPATestPlugin.java:142)
at
com.ibm.sysmgmt.resource.caching.jpa.test.JPATestPlugin.main(JPATestPlugin.java:79)

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message