I have the following issue when unit tests are executed (with the default ones created using spring-boot-starter).
Here is the issue :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method camundaBpmRestInitializer in org.camunda.bpm.spring.boot.starter.rest.CamundaBpmRestJerseyAutoConfiguration required a bean of type 'org.springframework.boot.autoconfigure.web.servlet.JerseyApplicationPath' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'jerseyApplicationPath' in 'JerseyAutoConfiguration' not loaded because not a servlet web application
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.boot.autoconfigure.web.servlet.JerseyApplicationPath' in your configuration.
StackTrace :
15:27:33.683 [main] ERROR o.s.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@732f29af] to prepare test instance [ch.vaudoise.camunda.changeaddresses.ProcessScenarioTest@7d0333c8]
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'camundaBpmRestInitializer' defined in class path resource [org/camunda/bpm/spring/boot/starter/rest/CamundaBpmRestJerseyAutoConfiguration.class]: Unsatisfied dependency expressed through method 'camundaBpmRestInitializer' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.autoconfigure.web.servlet.JerseyApplicationPath' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.autoconfigure.web.servlet.JerseyApplicationPath' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Any ideas ? Never had this issue before with other projects …
thanks for your message! Seems like there were some changes introduced into the Spring Boot Starter that causes this problem.
To make the test run again, it should be sufficient to remove the (webEnvironment = WebEnvironment.NONE) from your test.
When it comes to testing in Spring Boot environments, the best practice would be to choose one of the two following options:
run the test as a @SpringBootTest , but maybe not with the full application context (to speed up test execution time). This was the goal behind switching off the WebEnvironment initially - but this now breaks with the later version with the starter. So slicing the application context in a custom way would be recommended.
or
run a plain JUnit test without Spring Boot by using the ProcessEngineRule
I will try to have our archetypes adjusted in that regard soon.