Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-5345

NPE when setting HistoryLevel to "Activity" in SpringProcessEngineConfiguration

XMLWordPrintable

      In our Spring Application, when creating the ProcessEngineConfiguration, we are setting the HistoryLevel to Activity. Looks like this:

      @Bean
          public SpringProcessEngineConfiguration processEngineConfiguration() {
               ...
              final SpringProcessEngineConfiguration pec = new SpringProcessEngineConfiguration();
               ...
              pec.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_ACTIVITY);
               ...
              return pec;
          }
      

      When we start our application, we're getting this NPE:

      Caused by: java.lang.NullPointerException at org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd.execute(DetermineHistoryLevelCmd.java:30) at org.camunda.bpm.engine.impl.SchemaOperationsProcessEngineBuild.checkHistoryLevel(SchemaOperationsProcessEngineBuild.java:97)
      

      It happens here in DetermineHistoricLevelCmd.java when the loop accesses the historyLevels variable:

      if (databaseHistoryLevel != null) {
            for (final HistoryLevel historyLevel : historyLevels) {
              if (historyLevel.getId() == databaseHistoryLevel) {
                result = historyLevel;
                break;
              }
            }
      

      We think this happens because of this code in ProcessEngineConfigurationImpl.java :

      public void initHistoryLevel() {
      if(historyLevel == null) {
            if(historyLevels == null) {
              historyLevels = new ArrayList<HistoryLevel>();
              historyLevels.add(HistoryLevel.HISTORY_LEVEL_NONE);
              historyLevels.add(HistoryLevel.HISTORY_LEVEL_ACTIVITY);
              historyLevels.add(HistoryLevel.HISTORY_LEVEL_AUDIT);
              historyLevels.add(HistoryLevel.HISTORY_LEVEL_FULL);
            }
      

      historyLevels is only ever initialized when historyLevel is null - but in our case, historyLevel is already set to Activity, so historyLevels stays null, which causes the NPE. This happens since 7.4.

        This is the controller panel for Smart Panels app

              Unassigned Unassigned
              dietl@nbsp.de Matthias Dietl
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: