Devtools reload not working


#1

Hi friends,

I want to use Spring Boot Devtools to reload Camunda application during development. Unfortunately, that doesn’t work. During a reload my application fails with the following exception:

2017-09-22 18:30:34.585 ERROR 76464 --- [ost-startStop-1] o.a.c.c.C.[.[localhost].[/camunda]       : Exception starting filter [Engines Filter]

java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@107718a9 has been closed already
	at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1062)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)
	at org.camunda.bpm.spring.boot.starter.webapp.filter.LazyInitRegistration.getInitHook(LazyInitRegistration.java:33)
	at org.camunda.bpm.spring.boot.starter.webapp.filter.LazyInitRegistration.lazyInit(LazyInitRegistration.java:45)
	at org.camunda.bpm.spring.boot.starter.webapp.filter.LazyDelegateFilter.init(LazyDelegateFilter.java:39)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4590)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Any hints? Has anyone been able to successfully use devtools reload feature with camunda spring boot?

My environment: Gradle, Camunda 7.6 with Camunda Spring Boot Starter 2.1.2


#2

Hi @tair ,
could you may be post the sample application? I’ve just tested - hot-restart works fine for me on this example on v.2.2.0: https://github.com/camunda/camunda-bpm-spring-boot-starter/tree/2.2.0/examples/example-web


#3

Hi @sdorokhova,

I tried this one https://github.com/camunda/camunda-bpm-spring-boot-starter/tree/2.2.0/examples/example-webapp-gradle, added runtime 'org.springframework.boot:spring-boot-devtools' dependency, and it also fails with exception at reload


#4

Hi @tair,

I tried and faced the same error. At the same time similar Maven project works fine (https://github.com/camunda/camunda-bpm-spring-boot-starter/tree/2.2.0/examples/example-webapp) Can’t actually say, why the problem happens, usually I’m not using Gradle .


#5

Thank you @sdorokhova,

I really think there is some issue with camunda-gradle-spring-boot combination, because without camunda gradle + spring-boot reload is fine :frowning:


#6

Hi @tair,

I’ve created the bug report for this issue: https://app.camunda.com/jira/browse/CAM-8261
Hopefully someone from community will be interested in researching and fixing this issue. Feel free to participate yourself :wink:


#7

Hi @tair,
FYI the related issue was fixed.
It will be released in v. 2.3.0. You can check this GitHub commit: https://github.com/camunda/camunda-bpm-spring-boot-starter/commit/23c2871c7662b4321baf2adde1f0e9642a5bc017.

Svetlana


#8

Thanks for getting this done, @sdorokhova!


#9

All the credits go to Camunda’s awesome community) Here is the original pull request: https://github.com/camunda/camunda-bpm-spring-boot-starter/pull/287


#10

Here is an easy workaround before release of 2.3.0:

@SpringBootApplication(exclude = CamundaBpmWebappAutoConfiguration.class)
@ProcessApplication
public class CamundaApplication {...}

@Configuration
@ConditionalOnWebApplication
@AutoConfigureAfter(CamundaBpmAutoConfiguration.class)
public class CustomCamundaBpmWebappAutoConfiguration extends CamundaBpmWebappAutoConfiguration {
    @Bean
    public LazyInitRegistration lazyInitRegistration() {
        return new LazyInitRegistration(){
            @EventListener
            protected void onContextClosed(ContextClosedEvent ev) {
                APPLICATION_CONTEXT = null;
            }
        };
    }
}