InvocationTargetException | Community
Skip to main content
Keerthi0555
Level 5
August 9, 2023
Solved

InvocationTargetException

  • August 9, 2023
  • 1 reply
  • 600 views

I'm getting target invocation exception at this line of my code

 

 Tag tag = resource.adaptTo(Tag.class);
The resource is not adapting to Tag tag is returning null.
 resource is not returning null, but getting target invocation exception.
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

Mainly 2 things to check:

1) Is the "Tag" imported from com.day.cq.tagging.Tag?

2) If the resource is a cq:Tag node resource

 

Reference:
https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/sling-adapters.html?lang=en#null-return-value 

1 reply

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
August 9, 2023

Mainly 2 things to check:

1) Is the "Tag" imported from com.day.cq.tagging.Tag?

2) If the resource is a cq:Tag node resource

 

Reference:
https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/sling-adapters.html?lang=en#null-return-value 

Esteban Bustamante