Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for IllegalStateException when stopping re-satrting an OSGI plugin with Jersey resources #31185

Closed
victoralfaro-dotcms opened this issue Jan 21, 2025 · 13 comments · Fixed by #31310 or #31259
Labels

Comments

@victoralfaro-dotcms
Copy link
Contributor

victoralfaro-dotcms commented Jan 21, 2025

Problem Statement

User Story

As a software engineer, I want a fix for an issue related to OSGI plugins. When stopping or undeploying an active OSGI plugin with a Jersey resource, dotCMS stops working and requires a full restart. This occurs due to a call to RestServiceUtil.removeResource(clazz) that throws an IllegalStateException.

Acceptance Criteria

  • A fix is implemented to prevent RestServiceUtil.removeResource(clazz) from causing an IllegalStateException when stopping or undeploying OSGI plugins.
  • Validate that dotCMS continues to operate without requiring a restart after stopping or undeploying an OSGI plugin with a Jersey resource.
  • Comprehensive unit and integration tests ensure the fix does not introduce regressions.
  • Proper documentation and changelog entry are added to reflect the fix.

dotCMS Version

master

Proposed Objective

Customer Support

Proposed Priority

Priority 1 - Show Stopper

External Links

Assumptions & Initiation Needs

  • The issue is reproducible in the latest master branch.
  • The CDI integration changes are confirmed as the root cause.
  • Collaboration with the QA team to validate scenarios and outcomes.

Quality Assurance Notes & Workarounds

  • Ensure the issue is consistently reproducible before applying the fix.
  • Use test OSGI plugins to simulate the stopping/undeploying process for verification.
  • Verify the fix does not impact other CDI-related functionality in dotCMS.

Sub-Tasks & Estimates

  1. Investigate the root cause of the IllegalStateException (3 hours).
  2. Implement a fix to handle the lifecycle of Jersey resources during plugin stopping (6 hours).
  3. Create unit tests to verify the fix (4 hours).
  4. Perform integration testing with OSGI plugins (6 hours).
  5. Update documentation and changelog (2 hours).

Steps to Reproduce

  • Start dotCMS
  • Go to plugin portlet
  • Upload a plugin jar that includes a Jersey resource in its code, (e.g. user registration)
  • Once started make sure it runs
  • Stop it and notice how dotCMS instance becomes unstable until you need to restart it

dotCMS Version

25.01.15

Proposed Objective

Code Maintenance

Proposed Priority

Priority 2 - Important

Link to Support ticket:

https://dotcms.freshdesk.com/a/tickets/29269

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

@spbolton
Copy link
Contributor

Note I think we may have been seeing a similar error message with previous version of Jersey and although we have an exception trace it didn't impact the whole server after restart of the context, The error message seemed to occur from an internal Jersey call that forms part of the request to restart. Unfortunately, we are restricted in bumping jersey up to a higher version without upgrading to tomcat 10

We have someone else here with the same message on an reload of the Jersey context
https://stackoverflow.com/questions/70792820/servicelocatorimpl-shutdown-issue-in-jersey-2-34

I want to raise this as the issue the customer is having with the server not working after the restart may not be directly related to the exception. We probably need to find the last version removing the plugin breaks the server and we may find the error message is still there, but we can then discover the real cause of the issue unless that version does no longer throw the exception. We should also look at any other indications of a problem in the log around this message

dotcms-1      | 1. java.lang.IllegalStateException: ServiceLocatorImpl(__HK2_Generated_5,5,196525911) has been shut down

@fabrizzio-dotCMS
Copy link
Contributor

What OSGI resource plugin can I use to reproduce this issue?

@nollymar nollymar moved this from New to Next 1-3 Sprints in dotCMS - Product Planning Jan 22, 2025
@fabrizzio-dotCMS fabrizzio-dotCMS self-assigned this Jan 28, 2025
@fabrizzio-dotCMS fabrizzio-dotCMS moved this from Next 1-3 Sprints to In Progress in dotCMS - Product Planning Jan 28, 2025
fabrizzio-dotCMS added a commit that referenced this issue Jan 29, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 29, 2025
…31259)

### Proposed Changes
* This comes to fix a jersey bug that leaves the application in a
useless state after stopping an OSG plugin
* The problem was caused by the ContainerReloader component that we had
to restart the Servlet container on the fly. This component shouldn't be
a Managed bean so it can survive a restart with no problem.
* This ContainerReloader was made singleton, as it used to be before we
added CDI
* I am removing CdiComponentProvider since it's an internal dependency
that is already part of Jersey
@github-project-automation github-project-automation bot moved this from In Progress to Done in dotCMS - Product Planning Jan 29, 2025
@fabrizzio-dotCMS fabrizzio-dotCMS moved this from Done to In Review in dotCMS - Product Planning Jan 30, 2025
@fabrizzio-dotCMS fabrizzio-dotCMS removed their assignment Jan 30, 2025
@zJaaal zJaaal reopened this Jan 30, 2025
@github-project-automation github-project-automation bot moved this from In Review to Current Sprint Backlog in dotCMS - Product Planning Jan 30, 2025
@zJaaal zJaaal moved this from Current Sprint Backlog to Internal QA in dotCMS - Product Planning Jan 30, 2025
@erickgonzalez erickgonzalez added the LTS: Next Patch Shortlisted of issues that will be included in the upcoming LTS patch label Feb 10, 2025
@rjvelazco rjvelazco reopened this Feb 10, 2025
@github-project-automation github-project-automation bot moved this from Done to Current Sprint Backlog in dotCMS - Product Planning Feb 10, 2025
@rjvelazco rjvelazco moved this from Current Sprint Backlog to Internal QA in dotCMS - Product Planning Feb 10, 2025
@rjvelazco
Copy link
Contributor

rjvelazco commented Feb 10, 2025

Failed IQA

  • Docker: [dotcms/dotcms:trunk_ 216ce44]

500 after re-uploading a plugin

  1. Go to Plugins
  2. Upload a Plugin
  3. Check the plugin is working
  4. Stop and Undeploy
  5. Try to upload the same plugin
  6. See the error

Note: It can be a plugin issue

Video

IQA-OSGI-PART-1.mov

Unable to stop/undeploy a plugin

  1. Go to Plugins
  2. Upload a Plugin with this name: rest-endpoint-example-0.2 (1).jar, notice that we are using white spaces and ().
  3. Attempt to stop/undeploy the plugin

Video

IAQ-OSGI-PART-2.mov

@fabrizzio-dotCMS
Copy link
Contributor

Looks like names with spaces are troublesome but that's another issue. Please create another card for that and let's focus on the reload stop problem we had. Thanks!

@rjvelazco rjvelazco moved this from Internal QA to In Progress in dotCMS - Product Planning Feb 11, 2025
@fabrizzio-dotCMS
Copy link
Contributor

fabrizzio-dotCMS commented Feb 11, 2025

Second issue will be handled here: #31348

@rjvelazco
Copy link
Contributor

After a conversation with @fabrizzio-dotCMS and due to support requirements, I will create a ticket for each issue found and move this ticket to done.

cc: @nollymar @fabrizzio-dotCMS

@github-project-automation github-project-automation bot moved this from In Progress to Done in dotCMS - Product Planning Feb 11, 2025
@fabrizzio-dotCMS fabrizzio-dotCMS changed the title Fix for IllegalStateException when stopping or undeploying an OSGI plugin with Jersey resources Fix for IllegalStateException when stopping restrting an OSGI plugin with Jersey resources Feb 11, 2025
@fabrizzio-dotCMS fabrizzio-dotCMS changed the title Fix for IllegalStateException when stopping restrting an OSGI plugin with Jersey resources Fix for IllegalStateException when stopping resatrting an OSGI plugin with Jersey resources Feb 11, 2025
@fabrizzio-dotCMS fabrizzio-dotCMS changed the title Fix for IllegalStateException when stopping resatrting an OSGI plugin with Jersey resources Fix for IllegalStateException when stopping re-satrting an OSGI plugin with Jersey resources Feb 11, 2025
erickgonzalez added a commit that referenced this issue Feb 14, 2025
@erickgonzalez erickgonzalez added the LTS: Excluded Ticket that has been excluded from at least one LTS label Feb 14, 2025
@erickgonzalez
Copy link
Contributor

Only for 24.12 LTS

@erickgonzalez erickgonzalez added Release : 24.12.27 v2 Included in LTS patch release 24.12.27 v2 and removed LTS: Next Patch Shortlisted of issues that will be included in the upcoming LTS patch labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment