Confluence DC won't start after upgrade with error : Invocation of init method failed; nested exception is java.lang.ClassCastException
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Confluence DC will not start after the upgrade with the error: Invocation of init method failed; nested exception is java.lang.ClassCastException
Environment
Confluence Data Center
Diagnosis
When upgrading Confluence, after the upgrade has been completed, Confluence will not start and the above error will be noted in the UI. The full error stack might look something like this:
xxxx-xx-xx xx:xx:xxx ERROR [Catalina-utility-x] [ContainerBase.[Standalone].[localhost].[/]] log Exception starting filter [legacyRemoteApiEventPublishingFilter]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehCacheConfigManager' defined in URL [jar:file:/<confluence-install>/confluence/WEB-INF/lib/confluence-cache-ehcache-7.13.2.jar!/cacheProviderContext.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: class com.atlassian.cache.ehcache.DelegatingCachedReference cannot be cast to class com.atlassian.cache.Cache (com.atlassian.cache.ehcache.DelegatingCachedReference and com.atlassian.cache.Cache are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @1301b96f)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1769)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:514)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:319)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:866)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at com.atlassian.spring.container.ContainerContextLoaderListener.contextInitialized(ContainerContextLoaderListener.java:32)
at com.atlassian.confluence.setup.ConfluenceBootstrappedContextLoaderListener.contextInitialized(ConfluenceBootstrappedContextLoaderListener.java:40)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4716)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5172)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassCastException: class com.atlassian.cache.ehcache.DelegatingCachedReference cannot be cast to class com.atlassian.cache.Cache (com.atlassian.cache.ehcache.DelegatingCachedReference and com.atlassian.cache.Cache are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @1301b96f)
at com.atlassian.cache.impl.AbstractCacheManager.getCache(AbstractCacheManager.java:177)
at com.atlassian.cache.impl.AbstractCacheManager.getCache(AbstractCacheManager.java:135)
at com.atlassian.cache.impl.AbstractCacheManager.getCache(AbstractCacheManager.java:114)
at com.atlassian.confluence.cache.ehcache.EhCacheManager.getCache(EhCacheManager.java:182)
at com.atlassian.confluence.cache.ehcache.EhCacheConfigManager.reconfigureCacheFromConfig(EhCacheConfigManager.java:69)
at com.atlassian.confluence.cache.ehcache.EhCacheConfigManager.reconfigureCaches(EhCacheConfigManager.java:54)
at com.atlassian.confluence.cache.ehcache.EhCacheConfigManager.afterPropertiesSet(EhCacheConfigManager.java:41)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1828)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1765)
... 25 more
Cause
There could be some conflict with the cache-settings-overrides.properties for the upgraded Confluence.
Solution
Option 1
Verify if the cache-settings-overrides.properties file contains the below class :
cache.maxEntriesLocalHeap.com.atlassian.confluence.plugin.CachingPluginStateStore=2
If the above class is present in the cache-settings-overrides.properties file, update the above record to the below class and restart the instance as part of the workaround mentioned in the Bug - CONFSERVER-94958
cache.maxEntriesLocalHeap.com.atlassian.confluence.plugin.CachingPluginPersistentStateStore =2
Option 2
Delete the cache-settings-overrides.properties file and restart the instance :
<home-directory>/shared-home/config/cache-settings-overrides.properties
if you run Confluence on a single server.<shared-home>/config/cache-settings-overrides.properties
if you run Confluence in a cluster.
Note - The cache-settings-overrides.properties file stores the changes to the default cache size configurations from the UI under the General Configuration > Cache Management screen. Deleting this file changes the cache size configurations to default values in place of the custom values updated from the UI.