SpringBootProcessApplication attribute resolves to Optiona<Optional<String>>

XMLWordPrintable

    • Type: Bug Report
    • Resolution: Cannot Reproduce
    • Priority: L3 - Default
    • None
    • Affects Version/s: 7.10.3
    • Component/s: spring-boot
    • None

      Hello,
      In order to use my own task and execution listener i had to remove @EnableProcessApplication annotation from my springboot application and define my own configuration extending SpringBootProcessApplication like:

      @Configuration
      public class EngineConfiguration extends SpringBootProcessApplication {
      
          @Override
          public TaskListener getTaskListener() {
              System.out.println("I am here!");
              return super.getTaskListener();
          }
      
          @Override
          public ExecutionListener getExecutionListener() {
              System.out.println("I am here!");
              return super.getExecutionListener();
          }
      
      }
      

      the issue is this below exception:

      
      java.lang.IllegalStateException: Failed to load ApplicationContext
      
      	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
      	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
      	at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
      	at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
      	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      Caused by: java.lang.RuntimeException: java.lang.ClassCastException: java.util.Optional cannot be cast to java.lang.String
      	at org.camunda.bpm.engine.spring.application.SpringProcessApplication.onApplicationEvent(SpringProcessApplication.java:104)
      	at org.camunda.bpm.engine.spring.application.SpringProcessApplication.onApplicationEvent(SpringProcessApplication.java:51)
      	at com.td.tds.veritas.security.rivendell.engine.EngineConfiguration$$EnhancerBySpringCGLIB$$a0dde9c7.onApplicationEvent(<generated>)
      	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
      	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
      	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
      	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:398)
      	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:355)
      	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
      	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
      	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
      	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
      	at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127)
      	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
      	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
      	... 24 more
      Caused by: java.lang.ClassCastException: java.util.Optional cannot be cast to java.lang.String
      	at java.util.Optional.ifPresent(Optional.java:159)
      	at org.camunda.bpm.spring.boot.starter.SpringBootProcessApplication.afterPropertiesSet(SpringBootProcessApplication.java:85)
      	at org.camunda.bpm.engine.spring.application.SpringProcessApplication.onApplicationEvent(SpringProcessApplication.java:95)
      	... 39 more
      

      looks like that the attribute springApplicationName in SpringBootProcessApplication class resolves to Optional<Optional<String>> instead of Optional<String> which causes the above exception, i am not sure whether this is the spring issue or not, but i workaround it by reassigning the springApplicationName:

      @Configuration
      public class EngineConfiguration extends SpringBootProcessApplication {
         ...
          @Override
          public void afterPropertiesSet() throws Exception {
              springApplicationName = Optional.empty();
              super.afterPropertiesSet();
          }
      }
      

      setting application-name in application.properties didn't help.
      my fix is not the best fix so i'd appreciate if you could look into this.

      Thank you,
      Hazhir

        This is the controller panel for Smart Panels app

              Assignee:
              Unassigned
              Reporter:
              Hazhir Haghshenas
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: