1
votes

while trying to migrate to spring boot version 2.0, I faced the following issue when tried to run Junits. The same unit tests used to work on the spring boot version 1.5.8 but after changing the version they started to fail. The following is the stack trace to the issue. Could you please let me know what is the root cause for the same?

Application run failed java.lang.IllegalStateException:Error processing condition on org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration.pageableCustomizer|at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)|at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:109)|at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:179)|at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)|at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)|at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)|at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)|at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)|at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)|at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)|at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)|at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)|at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)|at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)|at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138)|at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)|at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)|at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107)|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:242)|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.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)|at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)|at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)|at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)|at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)|at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)|at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)|Caused by:java.lang.IllegalStateException:@ConditionalOnMissingBean did not specify a bean using type,name or annotation and the attempt to deduce the bean'stype failed|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.validate(OnBeanCondition.java:390)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.(OnBeanCondition.java:380)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:114)|at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)|...42 common frames omitted|Caused by:org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException:Failed to deduce bean type for org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration.pageableCustomizer|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.addDeducedBeanTypeForBeanMethod(OnBeanCondition.java:443)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.addDeducedBeanType(OnBeanCondition.java:427)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.(OnBeanCondition.java:374)|...44 common frames omitted|Caused by:java.lang.ClassNotFoundException:org.springframework.data.web.config.PageableHandlerMethodArgumentResolverCustomizer|at java.net.URLClassLoader.findClass(URLClassLoader.java:381)|at java.lang.ClassLoader.loadClass(ClassLoader.java:424)|at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)|at java.lang.ClassLoader.loadClass(ClassLoader.java:357)|at org.springframework.util.ClassUtils.forName(ClassUtils.java:264)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.addDeducedBeanTypeForBeanMethod(OnBeanCondition.java:437)|...46 common frames omitted|2018-05-10 09:32:00,391 INFO[main]GenericWebApplicationContext[]>:Closing org.springframework.web.context.support.GenericWebApplicationContext @71f bfa85:startup date[Thu May 10 09:31:59 IST 2018];root of context hierarchy

2018-05-10 09:32:00,393 ERROR[main]TestContextManager[]>:Caught exception while allowing TestExecutionListener[org.springframework.test.context.web.ServletTestExecutionListener @3e3894 ce]to prepare test instance[com.sap.bs.businesslogging.util.ConfigValidatorTest @748500f 3]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:107)|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:242)|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.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)|at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)|at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)|at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)|at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)|at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)|at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)|Caused by:java.lang.IllegalStateException:Error processing condition on org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration.pageableCustomizer|at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)|at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:109)|at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:179)|at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)|at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)|at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)|at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)|at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)|at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)|at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)|at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)|at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)|at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)|at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)|at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138)|at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)|at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)|...26 common frames omitted|Caused by:java.lang.IllegalStateException:@ConditionalOnMissingBean did not specify a bean using type,name or annotation and the attempt to deduce the bean'stype failed|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.validate(OnBeanCondition.java:390)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.(OnBeanCondition.java:380)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:114)|at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)|...42 common frames omitted|Caused by:org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException:Failed to deduce bean type for org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration.pageableCustomizer|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.addDeducedBeanTypeForBeanMethod(OnBeanCondition.java:443)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.addDeducedBeanType(OnBeanCondition.java:427)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.(OnBeanCondition.java:374)|...44 common frames omitted|Caused by:java.lang.ClassNotFoundException:org.springframework.data.web.config.PageableHandlerMethodArgumentResolverCustomizer|at java.net.URLClassLoader.findClass(URLClassLoader.java:381)|at java.lang.ClassLoader.loadClass(ClassLoader.java:424)|at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)|at java.lang.ClassLoader.loadClass(ClassLoader.java:357)|at org.springframework.util.ClassUtils.forName(ClassUtils.java:264)|at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.addDeducedBeanTypeForBeanMethod(OnBeanCondition.java:437)|...46 common frames omitted

3
Looks straightforward: Caused by:java.lang.ClassNotFoundException:org.springframework.data.web.config.PageableHandlerMethodArgumentResolverCustomizerRoddy of the Frozen Peas

3 Answers

1
votes

As Roddy pointed out, the error happened due to missing org.springframework.data.web.config.PageableHandlerMethodArgumentResolverCustomizer.

Do you have any Spring Data dependency in your POM.xml? For instance, spring-data-jpa.

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
    </dependency>
0
votes

In my case it was SpringDataWebAutoConfiguration that was triggered (when it shouldn't be) and it had problem with missing class on classpath PageableHandlerMethodArgumentResolverCustomizer. However I did not include spring-data in my dependencies, so I had to exclude it. Here's sample code how to do it in gradle:

configurations {
    compile.exclude module: 'spring-data-commons'
}
0
votes

You need to add a dependency on spring-boot-starter-data-redis and remove the one on spring-data-redis if you have one.