ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.88k stars 514 forks source link

Application fails to start with StackOverflowError #209

Closed steinwelberg closed 3 years ago

steinwelberg commented 4 years ago

When I integrate Jasypt version 3.0.2 into my application I receive a StackOverflowError and my application won't start.

Versions:

I have followed the steps to integrate Jasypt into my application and when I start the application I see the following stacktrace:

Stacktrace ``` 2020-04-16 08:08:57.806 WARN 82601 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.beanvalidation.MethodValidationPostProcessor]: Factory method 'methodValidationPostProcessor' threw exception; nested exception is java.lang.StackOverflowError 2020-04-16 08:08:57.806 INFO 82601 --- [ main] o.s.s.c.ThreadPoolTaskExecutor : Shutting down ExecutorService 'threadPoolTaskExecutor' 2020-04-16 08:08:57.819 INFO 82601 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-04-16 08:08:57.827 ERROR 82601 --- [ main] o.s.b.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.beanvalidation.MethodValidationPostProcessor]: Factory method 'methodValidationPostProcessor' threw exception; nested exception is java.lang.StackOverflowError at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:228) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:722) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at com.example.app.Application.main(Application.java:29) [classes/:?] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.beanvalidation.MethodValidationPostProcessor]: Factory method 'methodValidationPostProcessor' threw exception; nested exception is java.lang.StackOverflowError at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] ... 19 more Caused by: java.lang.StackOverflowError at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1012) ~[?:?] at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1541) ~[?:?] at java.lang.ClassLoader.getClassLoadingLock(ClassLoader.java:667) ~[?:?] at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:593) ~[?:?] at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[?:?] at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[?:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?] at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?] at java.lang.ClassLoader.defineClass(ClassLoader.java:1016) ~[?:?] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[?:?] at jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802) ~[?:?] at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700) ~[?:?] at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623) ~[?:?] at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[?:?] at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[?:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:380) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:320) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:448) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:90) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:79) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:56) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:452) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:572) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:558) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.access$400(Binder.java:513) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:450) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:391) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:320) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:308) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:238) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:225) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at com.ulisesbocchio.jasyptspringboot.properties.JasyptEncryptorConfigurationProperties.bindConfigProps(JasyptEncryptorConfigurationProperties.java:50) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.createDefault(DefaultLazyPropertyFilter.java:41) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.lambda$null$2(DefaultLazyPropertyFilter.java:32) ~[jasypt-spring-boot-3.0.2.jar:?] at java.util.Optional.orElseGet(Optional.java:369) ~[?:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.lambda$new$3(DefaultLazyPropertyFilter.java:26) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.util.Singleton.lambda$new$6(Singleton.java:42) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.util.Singleton.get(Singleton.java:53) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.shouldInclude(DefaultLazyPropertyFilter.java:49) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:18) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource.getProperty(CachingDelegateEncryptablePropertySource.java:38) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.wrapper.EncryptablePropertySourceWrapper.getProperty(EncryptablePropertySourceWrapper.java:33) ~[jasypt-spring-boot-3.0.2.jar:?] at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.find(SpringConfigurationPropertySource.java:111) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.find(SpringConfigurationPropertySource.java:100) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.getConfigurationProperty(SpringConfigurationPropertySource.java:84) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.findConfigurationProperty(ConfigurationPropertySourcesPropertySource.java:65) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.findConfigurationProperty(ConfigurationPropertySourcesPropertySource.java:53) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.getProperty(ConfigurationPropertySourcesPropertySource.java:42) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver.resolvePlaceholder(PropertySourcesPlaceholdersResolver.java:65) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:157) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver.resolvePlaceholders(PropertySourcesPlaceholdersResolver.java:57) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindProperty(Binder.java:434) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:380) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:320) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:448) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:90) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:79) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:56) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:452) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:572) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:558) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.access$400(Binder.java:513) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:450) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:391) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:320) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:308) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:238) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:225) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at com.ulisesbocchio.jasyptspringboot.properties.JasyptEncryptorConfigurationProperties.bindConfigProps(JasyptEncryptorConfigurationProperties.java:50) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.createDefault(DefaultLazyPropertyFilter.java:41) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.lambda$null$2(DefaultLazyPropertyFilter.java:32) ~[jasypt-spring-boot-3.0.2.jar:?] at java.util.Optional.orElseGet(Optional.java:369) ~[?:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.lambda$new$3(DefaultLazyPropertyFilter.java:26) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.util.Singleton.lambda$new$6(Singleton.java:42) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.util.Singleton.get(Singleton.java:53) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.shouldInclude(DefaultLazyPropertyFilter.java:49) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:18) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource.getProperty(CachingDelegateEncryptablePropertySource.java:38) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.wrapper.EncryptablePropertySourceWrapper.getProperty(EncryptablePropertySourceWrapper.java:33) ~[jasypt-spring-boot-3.0.2.jar:?] at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.find(SpringConfigurationPropertySource.java:111) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.find(SpringConfigurationPropertySource.java:100) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.getConfigurationProperty(SpringConfigurationPropertySource.java:84) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.findConfigurationProperty(ConfigurationPropertySourcesPropertySource.java:65) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.findConfigurationProperty(ConfigurationPropertySourcesPropertySource.java:53) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.getProperty(ConfigurationPropertySourcesPropertySource.java:42) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver.resolvePlaceholder(PropertySourcesPlaceholdersResolver.java:65) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:157) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver.resolvePlaceholders(PropertySourcesPlaceholdersResolver.java:57) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindProperty(Binder.java:434) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:380) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:320) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:448) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:90) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:79) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:56) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:452) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:572) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:558) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder$Context.access$400(Binder.java:513) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:450) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:391) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:320) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:308) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:238) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:225) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] at com.ulisesbocchio.jasyptspringboot.properties.JasyptEncryptorConfigurationProperties.bindConfigProps(JasyptEncryptorConfigurationProperties.java:50) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.createDefault(DefaultLazyPropertyFilter.java:41) ~[jasypt-spring-boot-3.0.2.jar:?] at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.lambda$null$2(DefaultLazyPropertyFilter.java:32) ~[jasypt-spring-boot-3.0.2.jar:?] at java.util.Optional.orElseGet(Optional.java:369) ~[?:?] ... ```

Before the stacktrace I see the following log message 142 times:

2020-04-16 08:08:57.443  INFO 82601 --- [           main] c.u.j.f.DefaultLazyPropertyFilter        : Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter

And before that I see that my property files get wrapped into the EncryptableMapPropertySourceWrapper object:

2020-04-16 08:08:57.207  INFO 82601 --- [           main] c.u.j.EncryptablePropertySourceConverter : Converting PropertySource applicationConfig: [classpath:/application.properties] [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
graham-macmaster commented 4 years ago

I'm experiencing the same, starting with version 3.0.1.

Versions:

I'm sticking with 3.0.0 for now as I'm not having problems there.

rupert-madden-abbott commented 4 years ago

@gmacster @steinwelberg are you able to upload a minimal example repository that replicates the bug? If so, I can take a look at trying to fix it.

graham-macmaster commented 4 years ago

@rupert-madden-abbott Minimal example uploaded at https://github.com/gmacster/jasypt-spring-boot-stackoverflowerror

It appears to only be an issue when jasypt.encryptor.password is defined in application.properties with a placeholder referencing another property (e.g. ${some.prop.value}). When I define it as a placeholder referencing an environment variable (e.g. ${some_env_var}), it works fine. Seems like a circular property source reference is getting constructed somehow.

The example has the following versions:

gsakthinarayanan commented 4 years ago

I am facing this issue as well with Spring Boot 2.2.8and jasypt-spring-boot-starter 3.0.3. I am trying to assign the jasypt encryptor password in application.properties file with the value from PCF Cred Hub service with VCAP property but the application fails to start with StackOverFlow exception.

jasypt.encryptor.password=${vcap.services.pcf-credhub-service.credentials.jasypt-password}

ulisesbocchio commented 4 years ago

Try excluding all vcap.* properties from being introspected. Check the readme for details on how to do that

gsakthinarayanan commented 4 years ago

Try excluding all vcap.* properties from being introspected. Check the readme for details on how to do that

I am confused on which exclusion property to use. Is it one of the below?

jasypt.encryptor.skip-property-sources= 
jasypt.encryptor.property.filter.exclude-names=
jasypt.encryptor.property.filter.exclude-sources=

As mentioned in my previous post, I assign the vcap services value to jasypt.encyptor.password. Isn't jasypt.encryptor already included in the exclusion list by DefaultPropertyFilter? jasypt.encryptor.password=${vcap.services.pcf-credhub-service.credentials.jasypt-password}

Below is the error that I receive:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.beanvalidation.MethodValidationPostProcessor]: Factory method 'methodValidationPostProcessor' threw exception; nested exception is java.lang.StackOverflowError
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]

Thanks in advance for your response.

ulisesbocchio commented 4 years ago

you can use:

jasypt.encryptor.property.filter.exclude-names=vcap.services.pcf-credhub-service.credentials.jasypt-password
// or
jasypt.encryptor.property.filter.exclude-names=vcap.services.pcf-credhub-service.credentials.*
// or, if you know the property source name and for instance is called "vcap-services"
jasypt.encryptor.property.filter.exclude-sources=vcap-services
gsakthinarayanan commented 4 years ago

I tried the above options already but it didn't help. I received the same StackOverflowError and the server failed to start.

ulisesbocchio commented 4 years ago

can you provide an example project where this happens? what option above did you actually used? Can I have a full stack trace? In the original stack trace (not from @gsakthinarayanan ) I see that DefaultLazyPropertyFilter is looping but I'm not sure in your case

ulisesbocchio commented 4 years ago

@gsakthinarayanan @gmacster @steinwelberg can you try this?

jasypt.encryptor.property.filter.exclude-names=jasypt.encryptor.password
gsakthinarayanan commented 4 years ago

I tried the above recommendation but still the same error. I created a sample repository that recreates the below issue.

With spring boot jasypt starter 3.0.3 (below issues do not occur with version 2.1.1):

Thanks for your response.

mrlonis commented 4 years ago

Any update on this? I am having the same exact issues described above.

Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter

Repeats about 20 times before failing with StackOverflow

ulisesbocchio commented 4 years ago

I found the issue. Haven’t had the chance to fix it yet

mrlonis commented 4 years ago

What is the issue?

Also, is there a version where the issue isn't present? I've seen some say version 3.0.0 is fine to use. Should I revert back to version 2.1.2?

ulisesbocchio commented 4 years ago

It has to do with the way the beans are lazily initialized. They look for a property but the property kicks in the encryption stuff which triggers to load the filters, and so on until it blows up.

mister-rao commented 4 years ago

Any update on this issue? I'm getting the same error:

o.s.c.s.AbstractApplicationContext.refresh 558 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration': Unsatisfied dependency expressed through field 'externalConfigurations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurableEnvironmentConfiguration' defined in class path resource [org/springframework/cloud/netflix/archaius/ArchaiusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.netflix.archaius.ConfigurableEnvironmentConfiguration]: Factory method 'configurableEnvironmentConfiguration' threw exception; nested exception is java.lang.StackOverflowError Related cause: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurableEnvironmentConfiguration': Requested bean is currently in creation: Is there an unresolvable circular reference? 00:41:51.790 [main] ERROR o.s.boot.SpringApplication.reportFailure 826 - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration': Unsatisfied dependency expressed through field 'externalConfigurations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurableEnvironmentConfiguration' defined in class path resource [org/springframework/cloud/netflix/archaius/ArchaiusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.netflix.archaius.ConfigurableEnvironmentConfiguration]: Factory method 'configurableEnvironmentConfiguration' threw exception; nested exception is java.lang.StackOverflowError at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSing

CarlosHerra commented 3 years ago

Same issue here when having the password in a PCF CredHub. Any updates? Thanks!

maxpavlovdp commented 3 years ago

I have upgraded from

1.7 to 3.0.3 and stackOverflow was fixed.
mfmarlow commented 3 years ago

having same issue when defining jasypt.encryptor.password as a reference. Using jasypt-spring-boot-starter 3.0.3 with spring boot 2.3.9

kable-wilmoth commented 3 years ago

Same issue. SpringBoot 2.3.10.RELEASE jasypt-spring-boot-starter 3.0.0 - WORKS jasypt-spring-boot-starter 3.0.1+ - FAILS

application.properties (really yaml) jasypt.encryptor.password=${some.other.property} - FAILS jasypt.encryptor.password=value - WORKS

jasypt 3.0.1 release notes: Usage of replacePlaceHolders instead of replaceRequiredPlaceholders on property resolver to mirror Spring's default behavior

pvandenbroucke commented 3 years ago

Hello,

Same issue here with spring-boot 2.4.5 -> 2.5.4 and jasypt-spring-boot-starter 3.0.3.

I have a configuration like : @EncryptablePropertySource(name = "EncryptedProperties", value = "classpath:credentials.properties", ignoreResourceNotFound = true)

The following log and stacktrace happen when the file is not provided :

INFO .EncryptablePropertySourceBeanFactoryPostProcessor [] Loading Encryptable Property Source 'EncryptedProperties' INFO .EncryptablePropertySourceBeanFactoryPostProcessor [] Ignoring NOT FOUND Encryptable Property Source 'EncryptedProperties' from locations: classpath:credentials.properties INFO c.u.j.EncryptablePropertySourceConverter [] Skipping PropertySource EncryptedProperties [class com.ulisesbocchio.jasyptspringboot.wrapper.EncryptableEnumerablePropertySourceWrapper INFO .EncryptablePropertySourceBeanFactoryPostProcessor [] Created Encryptable Property Source 'EncryptedProperties' from locations: [classpath:credentials.properties] INFO c.u.j.filter.DefaultLazyPropertyFilter [] Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter INFO c.u.j.filter.DefaultLazyPropertyFilter [] Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter INFO c.u.j.filter.DefaultLazyPropertyFilter [] Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter INFO c.u.j.filter.DefaultLazyPropertyFilter [] Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter ...

Caused by: java.lang.StackOverflowError: null at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:379) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:319) at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:447) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:95) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:83) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:59) at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:451) at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:571) at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:557) at org.springframework.boot.context.properties.bind.Binder$Context.access$300(Binder.java:512) at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:449) at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:390) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:319) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:308) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:238) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:225) at com.ulisesbocchio.jasyptspringboot.properties.JasyptEncryptorConfigurationProperties.bindConfigProps(JasyptEncryptorConfigurationProperties.java:50) at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.createDefault(DefaultLazyPropertyFilter.java:41) at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.lambda$null$2(DefaultLazyPropertyFilter.java:32) at java.util.Optional.orElseGet(Optional.java:267) at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.lambda$new$3(DefaultLazyPropertyFilter.java:26) at com.ulisesbocchio.jasyptspringboot.util.Singleton.lambda$new$6(Singleton.java:42) at com.ulisesbocchio.jasyptspringboot.util.Singleton.get(Singleton.java:53) at com.ulisesbocchio.jasyptspringboot.filter.DefaultLazyPropertyFilter.shouldInclude(DefaultLazyPropertyFilter.java:49) at com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:18) at com.ulisesbocchio.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource.getProperty(CachingDelegateEncryptablePropertySource.java:41) at com.ulisesbocchio.jasyptspringboot.wrapper.EncryptableEnumerablePropertySourceWrapper.getProperty(EncryptableEnumerablePropertySourceWrapper.java:23) at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.getConfigurationProperty(SpringConfigurationPropertySource.java:84)

ulisesbocchio commented 3 years ago

should go out next release