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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,922 views 0 7
Read article

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