Clearing the cache seems to lock up the MUC portion of openfire. The result is this curious trace:
the 'conference.jabber.company.com' is the local MUC
Removing the 'fix version' for all unresolved issues that were scheduled for version 7.8.2. We're releasing this version today - the remaining issues should be rescheduled later.
I'm gonna set this as a blocker to 4.0.0 as it is ugly
Still easily able to reproduce Placing against the next release.
This issue is caused by the components cache being cleared. The MUC engine registers each conference service as a separate component, and when all the caches are cleared, the cached components are effectively deleted until the next Openfire restart. This effect would be similarly true for any third-party plugins that use the Component API.
The stack trace indicates that the internal packet router does not recognize the registered component name (because it was removed from the component cache), and therefore tries to route the packet via an S2S connection. However, the component name is apparently still registered with the internal routing table, which then tries to cast the component handler as an outgoing session (via S2S). This is what causes the ClassCastException.
Potential solutions (from easiest to most difficult) include:
Exclude the components cache from the list of caches that can be cleared
Create an event/listener API to notify components when a given cache (or cache+key) is created/modified/deleted, then implement listener(s) to re-initialize components when needed
Refactor the component manager(s) and routing engine to avoid using a cache for registering components
There are some additional workaround options (like purging the internal routing table, test before cast, etc.), but none of these would address the root cause. Seems to me the first option above is probably sufficient in this case, as it is not likely that registered components should be silently disabled/removed via a cache management operation. However, it does expose a bigger issue in terms of how we want to handle lifecycle management concerns for Components (as we do with Plugins).
Disabled cache purging for the Components cache.