Uploaded image for project: 'Migration Platform'
  1. Migration Platform
  2. MIG-593

Fix the tracker lib to avoid class not found exceptions when the latest tracker lib is used with old CMAs.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • None
    • None
    • None
    • Minor

    Description

      Issue Summary

      When using the -tracker library with Jira with the default JCMA (1.4.4) the tracker library will fail with the error

      org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.atlassian.migration.app.tracker.CloudMigrationAccessor]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/atlassian/migration/app/BaseAppCloudMigrationListener 

      Steps to Reproduce

      1. Create an app using the -tracker library
      2. Install into Jira with the default JCMA 1.4.4

      Expected Results

      The app will load and not throw an error.

      Actual Results

      The below exception is thrown in the log file:

      2021-05-03 15:15:54,056+0100 http-nio-8080-exec-11 INFO admin 915x6288x1 wfaa3j 0:0:0:0:0:0:0:1 /rest/plugins/1.0/my-cloud-app-key-key [c.a.plugin.util.WaitUntil] Plugins that have yet to be enabled: (1): [my-cloud-app-key], 300 seconds remaining
      2021-05-03 15:15:54,195+0100 ThreadPoolAsyncTaskExecutor::Thread 187 ERROR admin 915x6288x1 wfaa3j 0:0:0:0:0:0:0:1 /rest/plugins/1.0/my-cloud-app-key-key [c.a.p.osgi.factory.OsgiPlugin] Unable to start the plugin container for plugin 'my-cloud-app-key'
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cloudMigrationAccessor': Initialization of bean failed; nested exception is java.lang.RuntimeException: Failed to initialise CloudMigrationAccessor
      ...
      Caused by: java.lang.RuntimeException: Failed to initialise CloudMigrationAccessor
      ...
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.atlassian.migration.app.tracker.CloudMigrationAccessor': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.atlassian.migration.app.tracker.CloudMigrationAccessor]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/atlassian/migration/app/BaseAppCloudMigrationListener
      ...
      Caused by: java.lang.NoClassDefFoundError: com/atlassian/migration/app/BaseAppCloudMigrationListener
      ...
      Caused by: java.lang.ClassNotFoundException: com.atlassian.migration.app.BaseAppCloudMigrationListener not found by com.atlassian.jira.migration.jira-migration-plugin [273]
      

      Workaround

      You can catch the ClassNotFoundException by using

      private static final Logger log = LoggerFactory.getLogger(LocalCloudMigrationAccessor.class);
      
          @Override
          public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
              try {
      
                  // check if com.atlassian.migration.app.BaseAppCloudMigrationListener can be created
                  // this will throw an exception if the class doesn't exist, and we skip loading the CloudMigrationAccessor
                  Class.forName("com.atlassian.migration.app.BaseAppCloudMigrationListener", false, getClass().getClassLoader());
                  this.registrar = (CloudMigrationAccessor) applicationContext.getAutowireCapableBeanFactory().
                          createBean(getClass().getClassLoader().loadClass("com.atlassian.migration.app.tracker.CloudMigrationAccessor"), AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
      
              } catch (Exception e) {
                  log.warn("Failed to initialise CloudMigrationAccessor. Ignoring.");
              }
          }

      Attachments

        Issue Links

          Activity

            People

              jrichards@atlassian.com James Richards
              jrichards@atlassian.com James Richards
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: