I'm trying to get a page's body, in a Confluence Job (extends com.atlassian.quartz.jobs.AbstractJob).
I get this error, here is the stack trace
[INFO] [talledLocalContainer] net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed [INFO] [talledLocalContainer] at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209) [INFO] [talledLocalContainer] at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71) [INFO] [talledLocalContainer] at net.sf.hibernate.collection.Bag.isEmpty(Bag.java:240) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyContent(ContentEntityObject.java:192) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyContent(ContentEntityObject.java:210) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyAsString(ContentEntityObject.java:251) [INFO] [talledLocalContainer] at com.cisco.confluence.actionitems.AdminJob2.doExecute(AdminJob2.java:91) [INFO] [talledLocalContainer] at com.atlassian.quartz.jobs.AbstractJob$1.doInHibernate(AbstractJob.java:133) [INFO] [talledLocalContainer] at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:370) [INFO] [talledLocalContainer] at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) [INFO] [talledLocalContainer] at com.atlassian.quartz.jobs.AbstractJob.executeInternal(AbstractJob.java:125) [INFO] [talledLocalContainer] at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86) [INFO] [talledLocalContainer] at com.atlassian.confluence.plugin.descriptor.JobModuleDescriptor$DelegatingPluginJob.execute(JobModuleDescriptor.java:151) [INFO] [talledLocalContainer] at com.atlassian.scheduler.quartz1.Quartz1JobFactory$ClassLoaderProtectingWrappedJob.execute(Quartz1JobFactory.java:62) [INFO] [talledLocalContainer] at org.quartz.core.JobRunShell.run(JobRunShell.java:223) [INFO] [talledLocalContainer] at com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool$1.run(ConfluenceQuartzThreadPool.java:22) [INFO] [talledLocalContainer] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [INFO] [talledLocalContainer] 2015-07-29 07:00:00,643 ERROR [scheduler_Worker-8] [org.quartz.core.JobRunShell] run Job com.cisco.confluence.actionitems.actionitems.ActionItemsAdminJob2 threw an unhandled Exception: [INFO] [talledLocalContainer] net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed [INFO] [talledLocalContainer] at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209) [INFO] [talledLocalContainer] at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71) [INFO] [talledLocalContainer] at net.sf.hibernate.collection.Bag.isEmpty(Bag.java:240) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyContent(ContentEntityObject.java:192) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyContent(ContentEntityObject.java:210) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyAsString(ContentEntityObject.java:251) [INFO] [talledLocalContainer] at com.cisco.confluence.actionitems.AdminJob2.doExecute(AdminJob2.java:91) [INFO] [talledLocalContainer] at com.atlassian.quartz.jobs.AbstractJob$1.doInHibernate(AbstractJob.java:133) [INFO] [talledLocalContainer] at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:370) [INFO] [talledLocalContainer] at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) [INFO] [talledLocalContainer] at com.atlassian.quartz.jobs.AbstractJob.executeInternal(AbstractJob.java:125) [INFO] [talledLocalContainer] at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86) [INFO] [talledLocalContainer] at com.atlassian.confluence.plugin.descriptor.JobModuleDescriptor$DelegatingPluginJob.execute(JobModuleDescriptor.java:151) [INFO] [talledLocalContainer] at com.atlassian.scheduler.quartz1.Quartz1JobFactory$ClassLoaderProtectingWrappedJob.execute(Quartz1JobFactory.java:62) [INFO] [talledLocalContainer] at org.quartz.core.JobRunShell.run(JobRunShell.java:223) [INFO] [talledLocalContainer] at com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool$1.run(ConfluenceQuartzThreadPool.java:22) [INFO] [talledLocalContainer] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [INFO] [talledLocalContainer] 2015-07-29 07:00:00,653 ERROR [scheduler_Worker-8] [org.quartz.core.ErrorLogger] schedulerError Job (com.cisco.confluence.actionitems.actionitems.ActionItemsAdminJob2 threw an exception. [INFO] [talledLocalContainer] org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed] [INFO] [talledLocalContainer] at org.quartz.core.JobRunShell.run(JobRunShell.java:234) [INFO] [talledLocalContainer] at com.atlassian.confluence.schedule.quartz.ConfluenceQuartzThreadPool$1.run(ConfluenceQuartzThreadPool.java:22) [INFO] [talledLocalContainer] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [INFO] [talledLocalContainer] Caused by: net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed [INFO] [talledLocalContainer] at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209) [INFO] [talledLocalContainer] at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71) [INFO] [talledLocalContainer] at net.sf.hibernate.collection.Bag.isEmpty(Bag.java:240) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyContent(ContentEntityObject.java:192) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyContent(ContentEntityObject.java:210) [INFO] [talledLocalContainer] at com.atlassian.confluence.core.ContentEntityObject.getBodyAsString(ContentEntityObject.java:251) [INFO] [talledLocalContainer] at com.cisco.confluence.actionitems.AdminJob2.doExecute(AdminJob2.java:91) [INFO] [talledLocalContainer] at com.atlassian.quartz.jobs.AbstractJob$1.doInHibernate(AbstractJob.java:133) [INFO] [talledLocalContainer] at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:370) [INFO] [talledLocalContainer] at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337) [INFO] [talledLocalContainer] at com.atlassian.quartz.jobs.AbstractJob.executeInternal(AbstractJob.java:125) [INFO] [talledLocalContainer] at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86) [INFO] [talledLocalContainer] at com.atlassian.confluence.plugin.descriptor.JobModuleDescriptor$DelegatingPluginJob.execute(JobModuleDescriptor.java:151) [INFO] [talledLocalContainer] at com.atlassian.scheduler.quartz1.Quartz1JobFactory$ClassLoaderProtectingWrappedJob.execute(Quartz1JobFactory.java:62) [INFO] [talledLocalContainer] at org.quartz.core.JobRunShell.run(JobRunShell.java:223) [INFO] [talledLocalContainer] ... 2 more
Community moderators have prevented the ability to post new answers.
Fixed it. As the Page if accessed from a Confluence Job needs to be done inside a "transaction".
Like the example at the end of this page https://developer.atlassian.com/confdev/confluence-plugin-guide/confluence-plugin-module-types/rpc-module
Hi Bleh, for some reasons I cannot access the example. Could please provide a snippet in which you get the page body? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.