Create
cancel
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

Hi!

I have an event listener in my custom Bitbucket plugin: 

 

@EventListener
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: ru.yandex.bitbucket.plugin.pull.jobs.merge.AutoMergingListener event: com.atlassian.bitbucket.event.task.TaskUpdatedEvent
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:55)
at com.atlassian.diagnostics.internal.platform.event.EventSystemMonitor.invokeMonitored(EventSystemMonitor.java:109)
at com.atlassian.diagnostics.internal.platform.event.MonitoredListenerInvoker.invoke(MonitoredListenerInvoker.java:38)
at com.atlassian.stash.internal.event.AsyncBatchingInvokersTransformer$AsyncInvokerBatch.invoke(AsyncBatchingInvokersTransformer.java:111)
at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.lambda$null$0(AsynchronousAbleEventDispatcher.java:37)
at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:34)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at com.atlassian.stash.internal.event.EventThreadFactory.lambda$createThread$0(EventThreadFactory.java:24)
at java.lang.Thread.run(Thread.java:748)
... 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(AbstractLazyInitializer.java:169)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:309)
at org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor.intercept(ByteBuddyInterceptor.java:45)
at org.hibernate.proxy.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:95)
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

my.custom.bitbucket.plugin.AutoMergingListener.onTaskUpdated(AutoMergingListener.java:56)
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:40)
... 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
TAGS
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