Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

org.hibernate.LazyInitializationException when accessing comment.getThread().getCommentable() Edited


I have an event listener in my custom Bitbucket plugin: 


public void onTaskUpdated(TaskUpdatedEvent event) {
    TaskAnchor anchor = event.getTask().getAnchor();
    if (anchor instanceof Comment) {
          Comment comment = (Comment) anchor;
          Commentable commentable = comment.getThread().getCommentable();

when accessing getCommentable() the following exception is thrown:

java.lang.RuntimeException: could not initialize proxy [com.atlassian.stash.internal.comment.InternalCommentThread#2004605] - no Session. Listener: event: com.atlassian.bitbucket.event.task.TaskUpdatedEvent
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(
at com.atlassian.diagnostics.internal.platform.event.EventSystemMonitor.invokeMonitored(
at com.atlassian.diagnostics.internal.platform.event.MonitoredListenerInvoker.invoke(
at com.atlassian.stash.internal.event.AsyncBatchingInvokersTransformer$AsyncInvokerBatch.invoke(
at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.lambda$null$0(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at com.atlassian.stash.internal.event.EventThreadFactory.lambda$createThread$0(
... 1 frame trimmed
Caused by: org.hibernate.LazyInitializationException: could not initialize proxy [com.atlassian.stash.internal.comment.InternalCommentThread#2004605] - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(
at org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor.intercept(
at org.hibernate.proxy.ProxyConfiguration$InterceptorDispatcher.intercept(
at com.atlassian.stash.internal.comment.InternalCommentThread$HibernateProxy$fCnlTUBi.getCommentable(Unknown Source)
at com.atlassian.stash.internal.comment.InternalCommentThread$HibernateProxy$fCnlTUBi.getCommentable(Unknown Source)

at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(
... 9 common frames omitted

adding @Transactional  does'n any effects. How I can restore session inside event listener?



0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Bitbucket

How do you use the Bitbucket-Jira integration? How does it help your team?

Hey everyone, over the past year, we've added several new features on how you can use Bitbucket and Jira together. We'd love to know how you'll are using the integration and how it's helping your t...

121 views 0 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you