{"action":"closed","issue":{"url":"https://api.github.com/repos/ulisesbocchio/jasypt-spring-boot/issues/89","repository_url":"https://api.github.com/repos/ulisesbocchio/jasypt-spring-boot","labels_url":"https://api.github.com/repos/ulisesbocchio/jasypt-spring-boot/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/ulisesbocchio/jasypt-spring-boot/issues/89/comments","events_url":"https://api.github.com/repos/ulisesbocchio/jasypt-spring-boot/issues/89/events","html_url":"https://github.com/ulisesbocchio/jasypt-spring-boot/issues/89","id":339920047,"node_id":"MDU6SXNzdWUzMzk5MjAwNDc=","number":89,"title":"Requested bean is currently in creation: Is there an unresolvable circular reference?","user":{"login":"Ravattailor","id":27134377,"node_id":"MDQ6VXNlcjI3MTM0Mzc3","avatar_url":"https://avatars0.githubusercontent.com/u/27134377?v=4","gravatar_id":"","url":"https://api.github.com/users/Ravattailor","html_url":"https://github.com/Ravattailor","followers_url":"https://api.github.com/users/Ravattailor/followers","following_url":"https://api.github.com/users/Ravattailor/following{/other_user}","gists_url":"https://api.github.com/users/Ravattailor/gists{/gist_id}","starred_url":"https://api.github.com/users/Ravattailor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ravattailor/subscriptions","organizations_url":"https://api.github.com/users/Ravattailor/orgs","repos_url":"https://api.github.com/users/Ravattailor/repos","events_url":"https://api.github.com/users/Ravattailor/events{/privacy}","received_events_url":"https://api.github.com/users/Ravattailor/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-07-10T16:34:22Z","updated_at":"2018-07-18T05:17:16Z","closed_at":"2018-07-18T05:17:16Z","author_association":"NONE","body":"`I` am trying to read the password from properties file but getting this exception. \r\n\r\nstack trace:-\r\n```\r\n``\r\nThe dependencies of some of the beans in the application context form a cycle:\r\n\r\n┌─────┐\r\n|  encryptablePropertyResolver defined in com.platform.core.config.PlatformEncryptionConfiguration\r\n└─────┘\r\n\r\n\r\n2018-07-10 21:51:46.442 ERROR 14685 --- [           main] o.s.boot.SpringApplication               : Application startup failed\r\n\r\norg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'encryptablePropertyResolver' defined in com.platform.core.config.PlatformEncryptionConfiguration: Unsatisfied dependency expressed through method 'encryptablePropertyResolver' parameter 0; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'encryptablePropertyResolver': Requested bean is currently in creation: Is there an unresolvable circular reference?\r\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:187) ~[spring-cloud-context-1.3.0.RELEASE.jar:1.3.0.RELEASE]\r\n\tat org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102) ~[spring-cloud-context-1.3.0.RELEASE.jar:1.3.0.RELEASE]\r\n\tat org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68) ~[spring-cloud-context-1.3.0.RELEASE.jar:1.3.0.RELEASE]\r\n\tat org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:296) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]\r\n\tat com.profectus.views.Application.main(Application.java:38) [classes/:na]\r\nCaused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'encryptablePropertyResolver': Requested bean is currently in creation: Is there an unresolvable circular reference?\r\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:347) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat com.ulisesbocchio.jasyptspringboot.resolver.DefaultLazyPropertyResolver.lambda$new$0(DefaultLazyPropertyResolver.java:28) ~[jasypt-spring-boot-2.0.0.jar:na]\r\n\tat java.util.Optional.map(Optional.java:215) ~[na:1.8.0_161]\r\n\tat com.ulisesbocchio.jasyptspringboot.resolver.DefaultLazyPropertyResolver.lambda$new$3(DefaultLazyPropertyResolver.java:28) ~[jasypt-spring-boot-2.0.0.jar:na]\r\n\tat com.ulisesbocchio.jasyptspringboot.util.Singleton.lambda$new$1(Singleton.java:20) ~[jasypt-spring-boot-2.0.0.jar:na]\r\n\tat com.ulisesbocchio.jasyptspringboot.util.Singleton.get(Singleton.java:31) ~[jasypt-spring-boot-2.0.0.jar:na]\r\n\tat com.ulisesbocchio.jasyptspringboot.resolver.DefaultLazyPropertyResolver.resolvePropertyValue(DefaultLazyPropertyResolver.java:41) ~[jasypt-spring-boot-2.0.0.jar:na]\r\n\tat com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:16) ~[jasypt-spring-boot-2.0.0.jar:na]\r\n\tat com.ulisesbocchio.jasyptspringboot.wrapper.EncryptableMapPropertySourceWrapper.getProperty(EncryptableMapPropertySourceWrapper.java:29) ~[jasypt-spring-boot-2.0.0.jar:na]\r\n\tat org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:81) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:61) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:527) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.context.support.PropertySourcesPlaceholderConfigurer$1.getProperty(PropertySourcesPlaceholderConfigurer.java:132) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.context.support.PropertySourcesPlaceholderConfigurer$1.getProperty(PropertySourcesPlaceholderConfigurer.java:129) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:81) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.core.env.PropertySourcesPropertyResolver.getPropertyAsRawString(PropertySourcesPropertyResolver.java:71) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.core.env.AbstractPropertyResolver$1.resolvePlaceholder(AbstractPropertyResolver.java:239) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:147) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:236) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:172) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:831) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1086) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]\r\n\t... 30 common frames omitted\r\n```\r\n\r\n\r\nMy configuration class\r\n\r\n```\r\n@Configuration\r\n@EnableEncryptableProperties\r\n@PropertySource(name = \"EncryptedProperties\", value = \"classpath:test-encrypted.properties\")\r\npublic class TestEncryptionConfiguration {\r\n\r\n\t\r\n\t@Bean(name = \"encryptablePropertyResolver\")\r\n\tEncryptablePropertyResolver encryptablePropertyResolver(@Value(\"${jasypt.encryptor.password}\") String password) {\r\n\t\treturn new MyEncryptablePropertyResolver(password);\r\n\t}\r\n\r\n\tclass MyEncryptablePropertyResolver implements EncryptablePropertyResolver {\r\n\r\n\t\tprivate final PooledPBEStringEncryptor encryptor;\r\n\r\n\t\tpublic MyEncryptablePropertyResolver(String password) {\r\n\t\t\tthis.encryptor = new PooledPBEStringEncryptor();\r\n\t\t\tSimpleStringPBEConfig config = new SimpleStringPBEConfig();\r\n\t\t\tconfig.setPasswordCharArray(password.toCharArray());\r\n\t\t\tconfig.setAlgorithm(\"PBEWithMD5AndDES\");\r\n\t\t\tconfig.setKeyObtentionIterations(\"1000\");\r\n\t\t\tconfig.setPoolSize(1);\r\n\t\t\tconfig.setProviderName(\"SunJCE\");\r\n\t\t\tconfig.setSaltGeneratorClassName(\"org.jasypt.salt.RandomSaltGenerator\");\r\n\t\t\tconfig.setStringOutputType(\"base64\");\r\n\t\t\tencryptor.setConfig(config);\r\n\t\t}\r\n\r\n\t\t@Override\r\n\t\tpublic String resolvePropertyValue(String value) {\r\n\t\t\tif (value != null && value.startsWith(\"{DES}\")) {\r\n\t\t\t\treturn encryptor.decrypt(value.substring(\"{DES}\".length()));\r\n\t\t\t}\r\n\t\t\treturn value;\r\n\t\t}\r\n\t}\r\n\r\n}\r\n```\r\n\r\ntest-encrypted.properties file:-\r\n\r\n```\r\njasypt.encryptor.bean=encryptorBean\r\njasypt.encryptor.password=password\r\njasypt.encryptor.property.prefix=\"{DES}\"\r\njasypt.encryptor.property.suffix=\"\"\r\njasypt.encryptor.property.resolver-bean=encryptablePropertyResolver\r\nsecret.property={DES}nrmZtkF7T0kjG/VodDvBw93Ct8EgjCA+\r\n```"}}
{"actor":{"display_login":"ulisesbocchio"}}