OSGI Rest Resource fails upon Redeploy with message: IllegalArgumentException: object is not an instance of declaring class #31348
Labels
dotCMS : OSGi
LTS: Needs Backport
Ticket that will be added to LTS
Team : Scout
Triage
Type : Defect
Parent Issue
#31185
Problem Statement
ClassLoader Conflict When Redeploying an OSGi Plugin that contains a Rest Resource that operates in Jersey
I was able to patch Jersey’s ServiceLocator so that we can stop and restart a resource loaded from an OSGi plugin without issues. However, I am now facing a new problem when undeploying and redeploying a JAR.
Root Cause:
This exception originates from JDK code and occurs because the resource method is being called via reflection. The validation logic in checkReceiver(Object o) ensures that the class of the object on which the method is invoked is assignable from the declaring class:
Upon debugging, I confirmed that the class names are identical, but the issue occurs because the class loaders are different after redeployment. This is expected behavior in OSGi, where each bundle may have its own ClassLoader, leading to type mismatches when invoking methods reflectively.
Possible Solutions
To resolve this, we need to:
Steps to Reproduce
Acceptance Criteria
We should be able to install un-install and continue to use the plugins with no problem
dotCMS Version
current trunk
Proposed Objective
Technical User Experience
Proposed Priority
Priority 2 - Important
External Links... Slack Conversations, Support Tickets, Figma Designs, etc.
No response
Assumptions & Initiation Needs
No response
Quality Assurance Notes & Workarounds
No response
Sub-Tasks & Estimates
No response
The text was updated successfully, but these errors were encountered: