org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role

494 views
Skip to first unread message

Seun Adewoye

unread,
Oct 17, 2022, 11:10:59 AM10/17/22
to DSpace Technical Support
Hi all, I need assistance in getting rid of this error. When I run bin/dspace index-discovery cammand, I keep getting this error:

The script has started
Updating Index
javax.persistence.PersistenceException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.dspace.content.DSpaceObject.metadata, could not initialize proxy - no Session
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1535)
        at org.hibernate.query.Query.getResultList(Query.java:165)
        at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76)
        at org.dspace.core.AbstractHibernateDAO.executeCriteriaQuery(AbstractHibernateDAO.java:428)
        at org.dspace.core.AbstractHibernateDAO.findAll(AbstractHibernateDAO.java:78)
        at org.dspace.core.AbstractHibernateDAO.findAll(AbstractHibernateDAO.java:70)
        at org.dspace.xmlworkflow.storedcomponents.PoolTaskServiceImpl.findAll(PoolTaskServiceImpl.java:52)
        at org.dspace.discovery.indexobject.PoolTaskIndexFactoryImpl.findAll(PoolTaskIndexFactoryImpl.java:42)
        at org.dspace.discovery.SolrServiceImpl.updateIndex(SolrServiceImpl.java:335)
        at org.dspace.discovery.SolrServiceImpl.updateIndex(SolrServiceImpl.java:325)
        at org.dspace.discovery.IndexClient.internalRun(IndexClient.java:133)
        at org.dspace.scripts.DSpaceRunnable.run(DSpaceRunnable.java:104)
        at org.dspace.app.launcher.ScriptLauncher.executeScript(ScriptLauncher.java:169)
        at org.dspace.app.launcher.ScriptLauncher.handleScript(ScriptLauncher.java:150)
        at org.dspace.app.launcher.ScriptLauncher.handleScript(ScriptLauncher.java:124)
        at org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:99)
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.dspace.content.DSpaceObject.metadata, could not initialize proxy - no Session
        at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:606)
        at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:218)
        at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:585)
        at org.hibernate.collection.internal.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:777)
        at org.hibernate.engine.internal.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:997)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:359)
        at org.hibernate.loader.Loader.doList(Loader.java:2815)
        at org.hibernate.loader.Loader.doList(Loader.java:2797)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2629)
        at org.hibernate.loader.Loader.list(Loader.java:2624)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:396)
        at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1396)
        at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1558)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1526)

Tim Donohue

unread,
Oct 18, 2022, 10:34:26 AM10/18/22
to DSpace Technical Support
Hi, 

What version of DSpace is this?   Usually the "could no initialize proxy - no Session" error is a sign of a larger problem in your DSpace setup.  Make sure to check your logs for other errors, as it's possible an earlier error resulted in this problem.  Here's our troubleshooting guide which will walk you through finding other error messages (depending on which version of DSpace you are using): https://wiki.lyrasis.org/display/DSPACE/Troubleshoot+an+error

It's also possible you are running an older version of DSpace 6.x (where this error did sometimes occur).  If so, I'd recommend upgrading to 6.4 to see if that solves the problem.

Please let us know what you find on this list & we'll see if we can provide better advice.

Tim

Seun Adewoye

unread,
Oct 18, 2022, 5:24:31 PM10/18/22
to DSpace Technical Support
Hi, team I am currently running DSpace Cris 7. As suggested, I will follow the troubleshooting guide to uncover other errors
Reply all
Reply to author
Forward
0 new messages