code: public static String getApplicationName(BundleContext bundleContext) {
          String applicationName = null;
          if (FrameworkState.isValid()) {
              ComponentMetaData cmd = ComponentMetaDataAccessorImpl.getComponentMetaDataAccessor().getComponentMetaData();
  
              if (cmd == null) {
                  //if the component metadata is null then we're probably running in the CDI startup sequence so try asking CDI for the application
                  applicationName = getCDIAppName(bundleContext);
              } else {
                  applicationName = cmd.getJ2EEName().getApplication();
              }
  
              if (applicationName == null) {
                  if (cmd == null) {
                      throw new ConfigStartException(Tr.formatMessage(tc, "no.application.name.CWMCG0201E"));
                  } else {
                      throw new ConfigException(Tr.formatMessage(tc, "no.application.name.CWMCG0201E"));
                  }
              }
          }
          return applicationName;
  
      }
docs: Get the j2ee name of the application. If the ComponentMetaData is available on the thread then that can be used, otherwise fallback
  to asking the CDIService for the name ... the CDI context ID is the same as the j2ee name.
  
  @param bundleContext The bundle context to use when looking up the CDIService
  @return the application name