java.lang.RuntimeException: com.atlassian.confluence.userstatus.UserStatus cannot be cast to com.atlassian.confluence.pages.AbstractPage

Atlassian JIRA | Romain Pouclet | 3 years ago
  1. 0

    I am currently working on a Confluence plugin that uses a ContentEntityObject subclass (= a UserStatus) and I ran into an issue. The user can like this ContentEntityObject, and it works when the user is trying to like his or her own content. Problem is, when the content is not his/her own, we get a RuntimeException: {noformat} [INFO] [talledLocalContainer] java.lang.RuntimeException: com.atlassian.confluence.userstatus.UserStatus cannot be cast to com.atlassian.confluence.pages.AbstractPage [INFO] [talledLocalContainer] at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54) [INFO] [talledLocalContainer] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66) [INFO] [talledLocalContainer] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32) [INFO] [talledLocalContainer] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60) [INFO] [talledLocalContainer] at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160) [INFO] [talledLocalContainer] at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79) [INFO] [talledLocalContainer] at com.atlassian.confluence.like.DefaultLikeManager.addLike(DefaultLikeManager.java:88) {noformat} That's because of the LikeEvent that is dispatched after the LikeEntity has been created, it seems there is a listener that expects an "AbstractPage" object with this event, which our object is not (here it's an UserStatus). It doesn't seem very logical to me to be able to like any ContentEntityObject but crash if you try to like something that is not a BlogPost or a Page.

    Atlassian JIRA | 3 years ago | Romain Pouclet
    java.lang.RuntimeException: com.atlassian.confluence.userstatus.UserStatus cannot be cast to com.atlassian.confluence.pages.AbstractPage
  2. 0

    I am currently working on a Confluence plugin that uses a ContentEntityObject subclass (= a UserStatus) and I ran into an issue. The user can like this ContentEntityObject, and it works when the user is trying to like his or her own content. Problem is, when the content is not his/her own, we get a RuntimeException: {noformat} [INFO] [talledLocalContainer] java.lang.RuntimeException: com.atlassian.confluence.userstatus.UserStatus cannot be cast to com.atlassian.confluence.pages.AbstractPage [INFO] [talledLocalContainer] at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54) [INFO] [talledLocalContainer] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66) [INFO] [talledLocalContainer] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32) [INFO] [talledLocalContainer] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60) [INFO] [talledLocalContainer] at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160) [INFO] [talledLocalContainer] at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79) [INFO] [talledLocalContainer] at com.atlassian.confluence.like.DefaultLikeManager.addLike(DefaultLikeManager.java:88) {noformat} That's because of the LikeEvent that is dispatched after the LikeEntity has been created, it seems there is a listener that expects an "AbstractPage" object with this event, which our object is not (here it's an UserStatus). It doesn't seem very logical to me to be able to like any ContentEntityObject but crash if you try to like something that is not a BlogPost or a Page.

    Atlassian JIRA | 3 years ago | Romain Pouclet
    java.lang.RuntimeException: com.atlassian.confluence.userstatus.UserStatus cannot be cast to com.atlassian.confluence.pages.AbstractPage
  3. 0

    Hello Atlassian, one of users receives the following error when he uses the like button: Failed to Save (something like that). In the atlassian-confluence.log we'll find this entry: {code} ERROR [http-8090-6] [atlassian.event.internal.EventPublisherImpl] invokeListeners There was an exception thrown trying to dispatch event 'com.atlassian.conf luence.event.events.like.LikeCreatedEvent@7aacb27f[user=EmbeddedCrowdUser{name='USER', displayName='USER', directoryId=1835009},content=page: PAGE v .2 (21334738),timestamp=1359369813723]' from the invoker 'com.atlassian.event.internal.SingleParameterMethodListenerInvoker@3280d257'. -- url: /rest/likes/1.0/content/21334738/likes | userName: USER | referer: http://URL/ java.lang.RuntimeException: Invalid recipient: null at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:60) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:28) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:56) at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:151) at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:70) at com.atlassian.confluence.like.DefaultLikeManager.addLike(DefaultLikeManager.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:16) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy84.addLike(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) {code} We also tried both suggested resolutions on https://confluence.atlassian.com/display/CONFKB/Like+Button+not+Working+after+Upgrade but it won't work for us.

    Atlassian JIRA | 4 years ago | Jan Szczepanski
    java.lang.RuntimeException: Invalid recipient: null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.RuntimeException

      com.atlassian.confluence.userstatus.UserStatus cannot be cast to com.atlassian.confluence.pages.AbstractPage

      at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke()
    2. com.atlassian.event
      EventPublisherImpl.publish
      1. com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54)
      2. com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66)
      3. com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32)
      4. com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60)
      5. com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160)
      6. com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79)
      6 frames
    3. com.atlassian.confluence
      DefaultLikeManager.addLike
      1. com.atlassian.confluence.like.DefaultLikeManager.addLike(DefaultLikeManager.java:88)
      1 frame