Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
Asked Answered
S

3

8

After adding 2 dependencies shown below to my application everything works fine my session data is written to my local redis server, but when i try to specify different address of redis server i got an error. I assume that error is connected with some dependencies problem, but i dont know how to tackle this issue.

compile "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springVersion}"
compile "org.springframework.session:spring-session-data-redis:${springVersion}"

Error during startup

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:180) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:61) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at pl.bk.pizza.store.Initializer.main(Initializer.java:11) [classes/:na] Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:569) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:599) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:724) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:665) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:633) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1489) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1012) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:164) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:153) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:203) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:115) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:265) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:254) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:196) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:116) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] ... 17 common frames omitted Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0-internal] at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0-internal] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0-internal] at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0-internal] at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0-internal] at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0-internal] at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0-internal] at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0-internal] at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0-internal] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0-internal] at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0-internal] at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0-internal] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0-internal] at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0-internal] at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0-internal] at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0-internal] at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0-internal] at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0-internal] at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0-internal] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0-internal] at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0-internal] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0-internal] at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0-internal] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] ... 35 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0-internal] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0-internal] ... 63 common frames omitted

RedisConfig

@Configuration
@EnableRedisHttpSession
public class RedisConfig
{
    @Bean
    LettuceConnectionFactory jedisConnectionFactory()
    {
        final RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
            config.setHostName("redis-19999.c14.us-east-1-2.ec2.cloud.redislabs.com");
            config.setPort(19999);
            config.setPassword(RedisPassword.of("***"));
        return new LettuceConnectionFactory();
    }
}

build.gradle file

buildscript {
    ext.springVersion = '2.0.2.RELEASE'
    ext.gradleDocker = '1.2'
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "se.transmode.gradle:gradle-docker:$gradleDocker"
        classpath "org.springframework.boot:spring-boot-gradle-plugin:$springVersion"
    }
}

plugins {
    id "org.sonarqube" version "2.6.2"
}

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
apply plugin: 'docker'
apply plugin: 'jacoco'

dependencies {

    // spring
    compile "org.springframework.boot:spring-boot-starter-webflux:${springVersion}"
    compile "org.springframework.boot:spring-boot-starter-data-mongodb-reactive:${springVersion}"
    compile "org.springframework.boot:spring-boot-starter-security:${springVersion}"
    testCompile "org.springframework.security:spring-security-test:${springSecurityTest}"
    testCompile "org.springframework.boot:spring-boot-starter-test:${springVersion}"
    compile "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springVersion}"
    compile "org.springframework.session:spring-session-data-redis:${springVersion}"

    // utils
    testCompile "org.assertj:assertj-core:${assertJ}"
    compile "com.google.guava:guava:${guava}"
    compile "io.projectreactor:reactor-core:${reactor}"
    compile "io.reactivex.rxjava2:rxjava:${rxjava}"
    compile "commons-lang:commons-lang:${commonsLang}"
    compile "commons-validator:commons-validator:${commonsLangValidator}"
    compileOnly "org.projectlombok:lombok:${lombok}"

    // embedded mongo for tests
    testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo:${embeddedMongo}"

    // spock
    compile "org.codehaus.groovy:groovy-all:${groovy}"
    testCompile "org.spockframework:spock-core:${spockCore}"
    testCompile "org.spockframework:spock-spring:${spockSpring}"
}
Stentorian answered 30/7, 2018 at 8:52 Comment(0)
N
3

There are several thing going on here.

The log you've supplied indicates javax.servlet.Filter is missing from the classpath while your build script and dependencies suggest your building a Spring WebFlux app. I suspect this is due to you explicitly configuring Spring Session's Servlet support using @EnableRedisHttpSession (notice HttpSession in there?) rather than @EnableRedisWebSession. Even better, you should leave Spring Session configuration to Spring Boot to auto-configure it - see Spring Session dedicated section of Spring Boot's reference manual.

The same advice (avoid explicit config, rely on auto-config) applies to your Redis configuration i.e. no need for that explicit LettuceConnectionFactory bean.

Furthermore, with Spring Boot, it's highly recommended to use its dependency management, rather then providing the versions of your dependency explicitly, at least for the dependencies that are covered by Spring Boot's dependency management. Refer to dependency management and dependency versions appendix sections of Boot's reference manual. On top of that, you should also strongly consider using Boot's starters to make sure all the required dependencies are pulled in - see starters dedicated section.

Narton answered 14/8, 2018 at 6:23 Comment(1)
Your answer is correct. I was using wrong annotation. Spring webflux is using Servlet 3.1 non-blocking IO, so lack of javax.servlet.Filter class on classpath is reasonable. I also applied other suggestion to my code about autoconfiguration and dependency managment. Thanks.Stentorian
U
1

This same error message presents if you create an application via spring initializr , specify Session as a dependency, create a @RestController and then use @EnableSpringHttpSession.

Without using @EnableSpringHttpSession, the application will start and exit, with no stack trace. This gives the appearance that perhaps there is something wrong with the HttpSession configuration.

The actual cause of the error condition is due to not having included Web as an application dependency (or implementation('org.springframework.boot:spring-boot-starter-web' in build.gradle)

Urea answered 8/11, 2018 at 21:27 Comment(0)
V
0

For me ,Everything is perfect but it still throws the exception-Propertyplaceholderautoconfiguration

I just tried maven reload and project reload ,still it throws this error and shows some red lines on dependency Class which is I used to import and used it in my project files

Just closed IntelliJ and opened the project again,Then Everything works fine. Thumbs up,If it is useful to you

Villar answered 17/6, 2021 at 17:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.