In Jira Data Center, third party plugin fails to enable with ClassNotFoundException
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
Plugin fails to enable and "This app couldn't be loaded. It has one or more errors that prevent it from being enabled" message is seen for the plugin in the Administration -> Manage Apps page
Environment
All Jira versions
Diagnosis
When the plugin is getting enabled, ClassNotFoundException/NoClassDefFoundError similar to the following are logged in atlassian-jira.log. In the example below, the com.atlassian.plugin.webresource.QueryParams class could not be loaded by the plugin 'plugin.tts'
2024-10-30 15:28:27,298+0000 UpmAsynchronousTaskManager:thread-4 ERROR admin [c.a.plugin.manager.DefaultPluginManager] There was an error loading the descriptor 'aui-progress-indicator-jira-7' of plugin 'plugin.tts'. Disabling.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.tuncaysenturk.jira.plugins.timetosla.webfragment.conditions.IsApplicationVersionCondition2': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.tuncaysenturk.jira.plugins.timetosla.webfragment.conditions.IsApplicationVersionCondition2] from ClassLoader [com.tuncaysenturk.jira.plugins.time-to-sla-plugin [243]]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:298)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1302)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1219)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:378)
at jdk.internal.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at com.atlassian.plugin.osgi.spring.DefaultSpringContainerAccessor.createBean(DefaultSpringContainerAccessor.java:118)
at com.atlassian.plugin.webresource.util.PluginClassLoader.create(PluginClassLoader.java:17)
at com.atlassian.plugin.webresource.condition.UrlReadingConditionElementParser.createObject(UrlReadingConditionElementParser.java:87)
<snip>
at com.atlassian.upm.core.async.AsynchronousTaskManager$1.call(AsynchronousTaskManager.java:100)
at com.atlassian.upm.core.async.AsynchronousTaskManager$1.call(AsynchronousTaskManager.java:97)
at com.atlassian.sal.core.executor.ThreadLocalDelegateCallable.call(ThreadLocalDelegateCallable.java:38)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.tuncaysenturk.jira.plugins.timetosla.webfragment.conditions.IsApplicationVersionCondition2] from ClassLoader [com.tuncaysenturk.jira.plugins.time-to-sla-plugin [243]]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:276)
... 124 more
Caused by: java.lang.NoClassDefFoundError: com/atlassian/plugin/webresource/QueryParams
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)
... 126 more
Caused by: java.lang.ClassNotFoundException: com.atlassian.plugin.webresource.QueryParams not found by com.tuncaysenturk.jira.plugins.time-to-sla-plugin [243]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1591)
at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1976)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
... 130 more
Cause
The ClassNotFoundException indicates that the class loader used by the JIRA plugin framework (Apache Felix OSGi) cannot find the class. This usually happens if the plugin's manifest is not correctly specifying its dependencies, or if there is a problem with the way dependencies are packaged with the plugin.
Solution
Engage the vendor of the plugin by providing the details of Jira version and Plugin version to validate if the specific plugin version is compatible with the Jira version.
For the example above, vendor released a newer version that is compatible and using this version resolved the problem.