Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-72156

ClassNotFoundException/NoClassDefFoundError (related to EventTriggerRuleComponent) is thrown when (some) apps are installed before Automation for Jira

      Issue Summary

      ClassNotFoundException/NoClassDefFoundError (related to the component EventTriggerRuleComponent or AutomationRuleComponent) is thrown when (some) apps are installed before Automation for Jira is installed or upgraded.

      This has been found with:

      • Third party sample app
      • ProForma: Forms and Fields for Jira
      • Profields - Jira Project Tracking

      Steps to Reproduce

      1. Build the attached "automation-thirdparty-sample-modified.zip" project. It is a trivially modified version of the official Automation sample app provided by Atlassian (https://bitbucket.org/atlassian/automation-addon-sample/src/master/automation-thirdparty-sample/).
        • LegacySampleCommentUpgradeTask class was removed to avoid an error during installation.
        • Marked the asterisk as optional in Import-Package to avoid this problem: JRASERVER-71831.
        • Compare the "pom.xml" with the original one to see some other minor differences.
        • Note: use "-Denforcer.skip=true" to avoid a build error with "atlas-package".
      2. Install the modified sample app in Jira.
      3. Install Automation for Jira.
      4. "ClassNotFoundException: com.codebarrel.automation.api.thirdparty.EventTriggerRuleComponent not found" appears in the Jira log, but the installation is successful.
      5. Create a new automation rule. Use trigger type "Issue commented" and add one "Log action" action with arbitrary message.
      6. Add a comment to an issue.
      7. "java.lang.NoClassDefFoundError: com/codebarrel/automation/api/thirdparty/EventTriggerRuleComponent" error appears in the audit log and the Jira log.
      8. Uninstall the modified sample app.
      9. Install the modified sample app.
      10. Add a comment to an issue.
      11. The rule is executed without error.

      Expected Results

      The third-party sample app and Automation for Jira can be installed in any order, no exceptions, automation rules are executed successfully.

      Actual Results

      When the third-party sample app is installed before Automation for Jira, the 3 symptoms below will (or might) be observed:

      Symptom 1:

      All automation rules will fail with the error below:

      Symptom 2:

      The Jira application logs will be flooded with the following ClassNotFoundException error:

      2022-11-15 09:33:13,212+0000 https-jsse-nio2-8443-exec-829 url: /browse/ABC-123, /secure/ProjectIssueNavigatorAction!issueViewWithSidebar.jspa; user: XXXXXX ERROR XXXXXX XXXxXXXXXXXXxXXX XXXXX XX.XX.XX.XX /browse/ABC-123 [c.a.event.internal.AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event [com.atlassian.jira.web.analytics.WebPanelRenderTimeEvent@508a3a88] from the invoker [SingleParameterMethodListenerInvoker{method=public void com.codebarrel.jira.plugin.automation.event.JiraIssueEventListenerImpl.handleAllOtherEvents(java.lang.Object), listener=com.codebarrel.jira.plugin.automation.event.JiraIssueEventListenerImpl@5ad1ed}]
      java.lang.RuntimeException: com/codebarrel/automation/api/thirdparty/EventTriggerRuleComponent. Listener: com.codebarrel.jira.plugin.automation.event.JiraIssueEventListenerImpl event: com.atlassian.jira.web.analytics.WebPanelRenderTimeEvent
      	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:53)
      	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.lambda$null$0(AsynchronousAbleEventDispatcher.java:37)
      	at com.atlassian.jira.event.JiraEventExecutorFactory$1.lambda$execute$0(JiraEventExecutorFactory.java:47)
      	at com.atlassian.jira.util.thread.JiraThreadLocalUtils.lambda$wrap$1(JiraThreadLocalUtils.java:156)
      	at com.atlassian.jira.event.JiraEventExecutorFactory$CallerRunsAlways.rejectedExecution(JiraEventExecutorFactory.java:87)
      	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
      	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
      	at com.atlassian.jira.event.JiraEventExecutorFactory$1.execute(JiraEventExecutorFactory.java:42)
      	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:85)
      	at com.atlassian.event.internal.LockFreeEventPublisher$Publisher.dispatch(LockFreeEventPublisher.java:220)
      
      ...
      
      	at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
      	... 30 filtered
      	at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
      	at sun.nio.ch.Invoker$2.run(Invoker.java:218)
      	at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
      	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
      	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.NoClassDefFoundError: com/codebarrel/automation/api/thirdparty/EventTriggerRuleComponent
      	at java.lang.ClassLoader.defineClass1(Native Method)
      	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
      	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.defineClass(BundleWiringImpl.java:2410)
      
      ... 
      
      Caused by: java.lang.ClassNotFoundException: com.codebarrel.automation.api.thirdparty.EventTriggerRuleComponent not found by com.deiser.jira.profields [201]
      	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
      	at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
      	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      

      Symptom 3:

      The Jira application might observe slowness/performance issues, due to the huge amount of logs being recorded using the log4j class. A lot of HTTP threads might end up in the BLOCKED status trying to write into the log files, waiting for a lock help by another thread also trying to write into the same log files. Example of stack trace of a BLOCKED thread:

      org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:231)
      com.atlassian.jira.logging.JiraHomeAppender.doAppend(JiraHomeAppender.java:206)
      org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:69)
      org.apache.log4j.Category.callAppenders(Category.java:219)
      org.apache.log4j.Category.forcedLog(Category.java:402)
      org.apache.log4j.Category.log(Category.java:869)
      org.slf4j.impl.Log4jLoggerAdapter.error(Log4jLoggerAdapter.java:562)
      com.atlassian.plugin.module.PrefixDelegatingModuleFactory.createModule(PrefixDelegatingModuleFactory.java:91)
      
      ...
      
      com.codebarrel.jira.plugin.automation.thirdparty.ThirdPartyComponentModuleDescriptor.getModule(ThirdPartyComponentModuleDescriptor.java:57)
      com.codebarrel.jira.plugin.automation.thirdparty.ThirdPartyComponentModuleTracker.getHandledEventClasses(ThirdPartyComponentModuleTracker.java:58)
      com.codebarrel.jira.plugin.automation.thirdparty.ThirdPartyComponentModuleTracker.lambda$getThirdPartyTriggers$0(ThirdPartyComponentModuleTracker.java:53)
      com.codebarrel.jira.plugin.automation.thirdparty.ThirdPartyComponentModuleTracker$$Lambda$18153/1421662149.test(Unknown Source)
      

      Workaround

      • Reinstall the interfering app.
        There should be no data/configuration loss as all the information is stored in the Jira database which is not affected by the reinstall.

            [JRASERVER-72156] ClassNotFoundException/NoClassDefFoundError (related to EventTriggerRuleComponent) is thrown when (some) apps are installed before Automation for Jira

            If you're a plugin vendor struggling with this issue (same type of issue can occur when importing JSW or JSM classes if JSM/JSW installed after your app) - you can add the affected packages into a new section after import-package:

            <DynamicImport-Package> com.codebarrel.automation.api.thirdparty.*</DynamicImport-Package>

            Then it will attempt to import it when trying to actually load the class, so works happily when your plugin enables before the one you depend on.

            Richard White [TechTime] added a comment - If you're a plugin vendor struggling with this issue (same type of issue can occur when importing JSW or JSM classes if JSM/JSW installed after your app) - you can add the affected packages into a new section after import-package: <DynamicImport-Package> com.codebarrel.automation.api.thirdparty.*</DynamicImport-Package> Then it will attempt to import it when trying to actually load the class, so works happily when your plugin enables before the one you depend on.

            Ferenc Nagy added a comment - - edited

            All right, thanks for your help so far!
            If we manage to find out something, we'll comment that here.
            Hopefully the A4J team will be able to give more insight to the root cause when they are available.

            Ferenc Nagy added a comment - - edited All right, thanks for your help so far! If we manage to find out something, we'll comment that here. Hopefully the A4J team will be able to give more insight to the root cause when they are available.

            Miro Capka added a comment -

            Hi ferenc.nagy, i wouldn't fully trust the sample app to work 100% out of the box as it is meant to serve as an example and not a modifiable and fully functional unit - taking into account the code progression of Jira over time. I think on your end you will need to do some more experimentation.
            The A4J team is not available at the moment to comment, but the more you test and supply stack traces, the easier it will be for them to help once they get to this.
            I'll do what I can on my end.

            Miro Capka added a comment - Hi ferenc.nagy , i wouldn't fully trust the sample app to work 100% out of the box as it is meant to serve as an example and not a modifiable and fully functional unit - taking into account the code progression of Jira over time. I think on your end you will need to do some more experimentation. The A4J team is not available at the moment to comment, but the more you test and supply stack traces, the easier it will be for them to help once they get to this. I'll do what I can on my end.

            Thanks for your suggestion, but we expect the sample app to work out-of-the-box. We just modified the asterisk to be optional in the "Import-Package" as suggested in the Atlassian documentation.
            Why we did this? Because there was a bug in the sample app that made it impossible to enable it when installed without Automation for Jira. (Imagine a situation where a third-party app has a big feature set and you want to add a small automation component, but with the default configuration the whole app cannot be enabled.)

            We have tried the following:

            1) Add the package to the "Import-Package" section:

            <Import-Package>
            	org.springframework.osgi.*;resolution:="optional",
            	org.eclipse.gemini.blueprint.*;resolution:="optional",
            	com.codebarrel.automation.api.thirdparty.*;resolution:="optional",
            	*;resolution:="optional"
            </Import-Package>

            The same exception was thrown.

            2) Add the component import to the "atlassian-plugin.xml":

            <component-import key="EventTriggerRuleComponent-test" interface="com.codebarrel.automation.api.thirdparty.EventTriggerRuleComponent" />
            

            It could not compile, as it's a Spring Scanner project:

            [ERROR] Failed to execute goal com.atlassian.maven.plugins:jira-maven-plugin:8.0.0:validate-manifest (default-validate-manifest) on project automation-thirdparty-sample:
            [ERROR]
            [ERROR] atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set.
            [ERROR]
            [ERROR] Please check the documentation of https://bitbucket.org/atlassian/atlassian-spring-scanner or https://developer.atlassian.com/display/DOCS/Configuration+of+Instructions+in+Atla
            ssian+Plugins for further details.

            What do you think about this?

             

            Ferenc Nagy added a comment - Thanks for your suggestion, but we expect the sample app to work out-of-the-box. We just modified the asterisk to be optional in the "Import-Package" as suggested in the Atlassian documentation . Why we did this? Because there was a bug in the sample app that made it impossible to enable it when installed without Automation for Jira. (Imagine a situation where a third-party app has a big feature set and you want to add a small automation component, but with the default configuration the whole app cannot be enabled.) We have tried the following: 1) Add the package to the "Import-Package" section: <Import-Package> org.springframework.osgi.*;resolution:= "optional" , org.eclipse.gemini.blueprint.*;resolution:= "optional" , com.codebarrel.automation.api.thirdparty.*;resolution:= "optional" , *;resolution:= "optional" </Import-Package> The same exception was thrown. 2) Add the component import to the "atlassian-plugin.xml": <component-import key="EventTriggerRuleComponent-test" interface="com.codebarrel.automation.api.thirdparty.EventTriggerRuleComponent" /> It could not compile, as it's a Spring Scanner project: [ERROR] Failed to execute goal com.atlassian.maven.plugins:jira-maven-plugin:8.0.0:validate-manifest (default-validate-manifest) on project automation-thirdparty-sample: [ERROR] [ERROR] atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set. [ERROR] [ERROR] Please check the documentation of https://bitbucket.org/atlassian/atlassian-spring-scanner or https://developer.atlassian.com/display/DOCS/Configuration+of+Instructions+in+Atla ssian+Plugins for further details. What do you think about this?  

            Miro Capka added a comment -

            ferenc.nagy 
            According to the stack trace you provided, just need to make sure you tried the following:

            UpmAsynchronousTaskManager:thread-3 ERROR admin 1082x4778x1 y9zbur 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [c.a.plugin.module.PrefixDelegatingModuleFactory] Detected an error (NoClassDefFoundError) instantiating the module for plugin ‘com.atlassian.automation.addon.automation-thirdparty-sample’ for module ‘project-created-trigger’: com/codebarrel/automation/api/thirdparty/EventTriggerRuleComponent. This error is usually caused by your plugin using a imported component class that itself relies on other packages in the product. You can probably fix this by adding the missing class’s package to your <Import-Package> instructions; for more details on how to fix this, see https://developer.atlassian.com/display/DOCS/NoClassDefFoundError .

            Cause: a plugin is lazily instantiated and then fails to find a needed class
            Solution: make sure the class and package name are correct and that the class is declared as a component in its atlassian-plugin.xml.

            Miro Capka added a comment - ferenc.nagy   According to the stack trace you provided, just need to make sure you tried the following: UpmAsynchronousTaskManager:thread-3 ERROR admin 1082x4778x1 y9zbur 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [c.a.plugin.module.PrefixDelegatingModuleFactory] Detected an error (NoClassDefFoundError) instantiating the module for plugin ‘com.atlassian.automation.addon.automation-thirdparty-sample’ for module ‘project-created-trigger’: com/codebarrel/automation/api/thirdparty/EventTriggerRuleComponent. This error is usually caused by your plugin using a imported component class that itself relies on other packages in the product. You can probably fix this by adding the missing class’s package to your <Import-Package> instructions; for more details on how to fix this, see  https://developer.atlassian.com/display/DOCS/NoClassDefFoundError  . Cause : a plugin is lazily instantiated and then fails to find a needed class Solution : make sure the class and package name are correct and that the class is declared as a  component  in its  atlassian-plugin.xml .

            The following step was lost when the "Steps to reproduce" section was copied from the related support ticket:

            11. The rule is executed without error.

            Ferenc Nagy added a comment - The following step was lost when the "Steps to reproduce" section was copied from the related support ticket: 11. The rule is executed without error.

              Unassigned Unassigned
              dmorrow@atlassian.com Dugald Morrow
              Affected customers:
              16 This affects my team
              Watchers:
              19 Start watching this issue

                Created:
                Updated: