SpaceDataSource initialDataLoad() - diagnosing hibernate exceptions
We are getting a hibernate exception (shown below) for one of the objects we are trying to load into a space using DefaultHibernateSpaceDataSource.initialDataLoad().
This object has a huge object graph, as it includes many JPA objects and they themselves include many other JPA objects. The exception we are getting does not identify the culprit object.
In order to get to the bottom of the problem, I am going to have to start removing some of the contained objects until I find out which one is causing the problem. In order to do this, I need to understand how the initialDataLoad process works.
*+Note that I am not asking for you to try and tell me why I'm getting the exception...just trying to get more information that will
My pu.xml looks something like this:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSourceOracle" />
<property name="annotatedClasses">
<list>
... about 75 classes ...
</list>
</property>
</bean>
<bean id="hibernateDataSource" class="com.csx.nbc.gigaload.TrafficHistorySpaceDataSource">
<constructor-arg name="sessionFactory" ref="sessionFactory"/>
<constructor-arg name="managedEntries">
<list>
... those same 75 classes ....
</list>
</constructor-arg>
<constructor-arg name="initialLoadEntries">
<list>
... those same 75 classes ....
</list>
</constructor-arg>
</bean>
As you can see, I duplicated the list of about 75 classes. I know I can use an annotation processor for 'managedEntries' and 'annotatedClasses' but I don't think I can for initialLoadEntries, right?
Question 1
Do I just put the classes directly referenced in the query under initialLoadEntries or do I put all the classes that they reference also?
Question 2
Is hibernate trying to load all classes when we get the exception or just the ones directly referenced in the query? In other words, if my main class (Location) includes several other classes, will I be helping myself by starting to remove other JPA objects from Location or is Hibernate going to try and load all the classes in the xml file regardless?
This is the exception:
2013-05-29 16:20:11,260 GSC SEVERE com.gigaspaces.grid.gsc - Failed to instantiate NBCGigaDataLoad 1; Caused by: org.jini.rio.core.JSBInstantiationException: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:94)
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:119)
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:71)
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:54)
at org.hibernate.loader.entity.BatchingEntityLoader.createBatchingEntityLoader(BatchingEntityLoader.java:133)
at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1914)
at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1937)
at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:3206)
at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:3192)
at org.hibernate.persister.entity.SingleTableEntityPersister.postInstantiate(SingleTableEntityPersister.java:728)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:348)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1504)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:587)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at org.openspaces.pu.container.integrated.IntegratedProcessingUnitContainerProvider.createContainer(IntegratedProcessingUnitContainerProvider.java:273)
at org.openspaces.pu.container.servicegrid.PUServiceBeanImpl.startPU(PUServiceBeanImpl.java:705)
at org.openspaces.pu.container.servicegrid.PUServiceBeanImpl.doStart(PUServiceBeanImpl.java:236)
at org.jini.rio.jsb.ServiceBeanAdapter$1.run(ServiceBeanAdapter.java:294)
at org.jini.rio.jsb.ServiceBeanAdapter.start(ServiceBeanAdapter.java:307)
at org.jini.rio.jsb.JSBLoader.create(JSBLoader.java:106)
at org.jini.rio.cybernode.ServiceBeanLoader.load(ServiceBeanLoader.java:276)
at org.jini.rio.cybernode.JSBDelegate.startServiceBean(JSBDelegate.java:475)
at org.jini.rio.cybernode.JSBDelegate.load(JSBDelegate.java:330)
at org.jini.rio.cybernode.JSBContainer.activate(JSBContainer.java:213)
at org.jini.rio.cybernode.CybernodeImpl.instantiate(CybernodeImpl.java:1054)
at org.jini.rio.core.provision.ServiceBeanInstantiatorGigaspacesMethodinternalInvoke3.internalInvoke(Unknown Source)
at com.gigaspaces.internal.reflection.fast.AbstractMethod.invoke(AbstractMethod.java:41)
at com.gigaspaces.lrmi.LRMIRuntime.invoked(LRMIRuntime.java:450)
at com.gigaspaces.lrmi.nio.Pivot.consumeAndHandleRequest(Pivot.java:557)
at com.gigaspaces.lrmi.nio.Pivot.handleRequest(Pivot.java:658)
at com.gigaspaces.lrmi.nio.Pivot$ChannelEntryTask.run(Pivot.java:196)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
This thread was imported from the previous forum.
For your reference, the original is available here