java.lang.RuntimeException: com.day.cq.wcm.api.WCMException: javax.jcr.ItemNotFoundException: No content resource for resource at path /content/myContentPage at com.day.cq.wcm.msm.impl.LiveRelationshipManagerImpl$LiveRelationshipIterator.next(LiveRelationshipManagerImpl.java:1152) [com.day.cq.wcm.cq-msm-core:5.13.60]
[...] Caused by: com.day.cq.wcm.api.WCMException: javax.jcr.ItemNotFoundException: No content resource for resource at path /content/myContentPage at com.day.cq.wcm.msm.impl.LiveRelationshipManagerImpl.buildRelationship(LiveRelationshipManagerImpl.java:869) [com.day.cq.wcm.cq-msm-core:5.13.60] at com.day.cq.wcm.msm.impl.LiveRelationshipManagerImpl.access$100(LiveRelationshipManagerImpl.java:81) [com.day.cq.wcm.cq-msm-core:5.13.60] at com.day.cq.wcm.msm.impl.LiveRelationshipManagerImpl$LiveRelationshipIterator.seek(LiveRelationshipManagerImpl.java:1107) [com.day.cq.wcm.cq-msm-core:5.13.60] at com.day.cq.wcm.msm.impl.LiveRelationshipManagerImpl$LiveRelationshipIterator.next(LiveRelationshipManagerImpl.java:1150) [com.day.cq.wcm.cq-msm-core:5.13.60] ... 24 common frames omitted Caused by: javax.jcr.ItemNotFoundException: No content resource for resource at path /content/myContentPage at com.day.cq.wcm.msm.impl.Utils.getContentResource(Utils.java:214) [com.day.cq.wcm.cq-msm-core:5.13.60] at com.day.cq.wcm.msm.impl.StatusUtil.createLiveStatus(StatusUtil.java:57) [com.day.cq.wcm.cq-msm-core:5.13.60] at com.day.cq.wcm.msm.impl.LiveRelationshipManagerImpl.buildRelationship(LiveRelationshipManagerImpl.java:856) [com.day.cq.wcm.cq-msm-core:5.13.60] ... 27 common frames omitted
I cannot skip this error because raised exception is a runtimeException so i'd prefer to understand why this exception occurred rather than catch it with a generic Exception.
I really cannot understand in which scenario this could happen. Do you think that some content has been deleted on publish server? How could the liveCopyRelationship have been broken?
Can someone help me to understand why often this issue appears?
While I haven't faced this exact exception yet, I would recommend the following to analyze the issue further:
You're saying that the issue only occurs on your publish instances. I'm a bit curious about why you would need to know about LiveCopy relationships on the publish tier, but that's a different question. I'm not even sure if all required LiveCopy information (e. g. properties and mixins) are replicated on publication. This would be a first step to do: compare the content between author and publish instance on a repository level and see if there are differences for the concerned pages.
Another topic that is common to be involved for differences between author and publish tier is user sessions and permissions: while on the author instance every user needs to log in before accessing the system (thus has a session and certain permissions according to his group memberships) on the publish side visitors often don't have to login and are assigned the "anonymous" role with very limited permissions. In this context it would be interesting to know what resourceResolver your code uses. Where does it come from? Does it have the necessary permissions (on the publish side) to access the concerned content?
If you are using a service user or your user (the one for the resourceResolver) has certain group membership, have you verified that the user(s) and the groups are replicated to the publish side as well?