Comments (23)
thanks for pointing that out, should be fixed now, there was an outdated pom.
After getting the latest sources run the following from wherever you checked out the repo:
mvn clean install
java -Djasypt.encryptor.password=password -jar jasypt-spring-boot-demo/target/jasypt-spring-boot-demo-0.1-SNAPSHOT.jar
from jasypt-spring-boot-samples.
Updated my maven project and still getting the same error. I ran SimpleDemoApplication.class from my IDE and not the command line as the command line was throwing a totally different error.
from jasypt-spring-boot-samples.
I verified the samples compile and work as expected, use the exact commands I sent you. From the IDE you gotta run the .java file, not the .class file.
The samples use the SNAPSHOT version jasypt-spring-boot so you gotta also download and build jasypt-spring-boot. If you don't want to do that, open the parent pom.xml in the samples repo and change the line:
<jasypt.spring.boot.version>1.9-SNAPSHOT</jasypt.spring.boot.version>
to
<jasypt.spring.boot.version>1.8</jasypt.spring.boot.version>
and build again
from jasypt-spring-boot-samples.
Ok. So now, i'm getting the same error in my IDE and from command line. Attaching a screenshot of my project structure.
What is the cause of Caused by: java.lang.IllegalArgumentException: Property source name must contain at least one character
Thanks in advance.
from jasypt-spring-boot-samples.
I see, that's not the sample project, I'm not sure what have you modified but whatever you have it's broken. The error is very specific though, it's telling you that wherever you defined a property source you haven't specified a name.
Can you upload that code to github for me to take a look?
from jasypt-spring-boot-samples.
I suggest you do a sanity check also by downloading again the sample project and without any modifications just run it and see what happens. Maybe just replace the jasypt.spring.boot.version property to 1.8 but nothing else
from jasypt-spring-boot-samples.
Did a sanity and still got the same error.
PFB
Also, attaching the pom.xml
from jasypt-spring-boot-samples.
Did you run this?
mvn clean install
java -Djasypt.encryptor.password=password -jar jasypt-spring-boot-demo/target/jasypt-spring-boot-demo-0.1-SNAPSHOT.jar
Paste the output of the second command
from jasypt-spring-boot-samples.
Pasting the requested information.
U:\git\jasypt-spring-boot-samples-actuals\jasypt-spring-boot-demo-simple\target>
java -Djasypt.encryptor.password=password -jar jasypt-spring-boot-demo-simple-0.
1-SNAPSHOT.jar
2016-10-13 11:07:07.694 DEBUG 14724 --- [ main] eEncryptablePropertySo
urcesPostProcessor : Application Event Raised: ApplicationEnvironmentPreparedEve
nt
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.3.RELEASE)
2016-10-13 11:07:08.579 INFO 14724 --- [ main] demo.SimpleDemoApplica
tion : Starting SimpleDemoApplication on FR1WVV99404 with PID 1472
4 (U:\git\jasypt-spring-boot-samples-actuals\jasypt-spring-boot-demo-simple\targ
et\jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar started by p10496 in U:\git\j
asypt-spring-boot-samples-actuals\jasypt-spring-boot-demo-simple\target)
2016-10-13 11:07:08.581 INFO 14724 --- [ main] demo.SimpleDemoApplica
tion : No active profile set, falling back to default profiles: de
fault
2016-10-13 11:07:08.966 DEBUG 14724 --- [ main] eEncryptablePropertySo
urcesPostProcessor : Application Event Raised: ApplicationPreparedEvent
2016-10-13 11:07:08.975 INFO 14724 --- [ main] s.c.a.AnnotationConfig
ApplicationContext : Refreshing org.springframework.context.annotation.Annotatio
nConfigApplicationContext@53ef6d06: startup date [Thu Oct 13 11:07:08 EDT 2016];
root of context hierarchy
2016-10-13 11:07:11.501 DEBUG 14724 --- [ main] c.u.j.c.StringEncrypto
rConfiguration : Registering new name 'encryptorBean' for Bean definition wi
th placeholder name: ${jasypt.encryptor.bean:jasyptStringEncryptor}
2016-10-13 11:07:12.210 INFO 14724 --- [ main] c.u.j.c.StringEncrypto
rConfiguration : String Encryptor custom Bean not found with name 'encryptor
Bean'. Initializing String Encryptor based on properties with name 'encryptorBea
n'
2016-10-13 11:07:12.253 INFO 14724 --- [ main] .c.EncryptableProperty
SourcesInitializer : Created Encryptable Property Source 'encrypted2' from locat
ions: [classpath:encrypted2.properties]
2016-10-13 11:07:12.256 WARN 14724 --- [ main] s.c.a.AnnotationConfig
ApplicationContext : Exception encountered during context initialization - cance
lling refresh attempt: org.springframework.context.ApplicationContextException:
Exception Creating PropertySource; nested exception is java.lang.IllegalArgument
Exception: Property source name must contain at least one character
2016-10-13 11:07:12.271 ERROR 14724 --- [ main] o.s.boot.SpringApplica
tion : Application startup failed
org.springframework.context.ApplicationContextException: Exception Creating Prop
ertySource; nested exception is java.lang.IllegalArgumentException: Property sou
rce name must contain at least one character
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.lo
adEncryptablePropertySource(EncryptablePropertySourcesInitializer.java:71)
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.la
mbda$postProcessBeanFactory$0(EncryptablePropertySourcesInitializer.java:58)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Sour
ce)
at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
at java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Sour
ce)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemain
ing(Unknown Source)
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Unknown S
ource)
at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.po
stProcessBeanFactory(EncryptablePropertySourcesInitializer.java:58)
at org.springframework.context.support.PostProcessorRegistrationDelegate
.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)
at org.springframework.context.support.PostProcessorRegistrationDelegate
.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)
at org.springframework.context.support.AbstractApplicationContext.invoke
BeanFactoryPostProcessors(AbstractApplicationContext.java:678)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:520)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.
java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(Sp
ringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java
:307)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringA
pplicationBuilder.java:134)
at demo.SimpleDemoApplication.main(SimpleDemoApplication.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
.java:54)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Property source name must contain
at least one character
at org.springframework.util.Assert.hasText(Assert.java:168)
at org.springframework.core.env.PropertySource.<init>(PropertySource.jav
a:71)
at org.springframework.core.env.PropertySource.<init>(PropertySource.jav
a:85)
at org.springframework.core.env.EnumerablePropertySource.<init>(Enumerab
lePropertySource.java:51)
at org.springframework.core.env.CompositePropertySource.<init>(Composite
PropertySource.java:52)
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.cr
eatePropertySource(EncryptablePropertySourcesInitializer.java:79)
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.lo
adEncryptablePropertySource(EncryptablePropertySourcesInitializer.java:63)
... 32 common frames omitted
2016-10-13 11:07:12.279 INFO 14724 --- [ main] .b.l.ClasspathLoggingA
pplicationListener : Application failed to start with classpath: [jar:file:/U:/g
it/jasypt-spring-boot-samples-actuals/jasypt-spring-boot-demo-simple/target/jasy
pt-spring-boot-demo-simple-0.1-SNAPSHOT.jar!/, jar:file:/U:/git/jasypt-spring-bo
ot-samples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-spring-boot-demo
-simple-0.1-SNAPSHOT.jar!/lib/jasypt-spring-boot-1.8.jar!/, jar:file:/U:/git/jas
ypt-spring-boot-samples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-spr
ing-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/jasypt-1.9.2.jar!/, jar:file:/U:/git/
jasypt-spring-boot-samples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-
spring-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/spring-boot-starter-1.3.3.RELEASE.
jar!/, jar:file:/U:/git/jasypt-spring-boot-samples-actuals/jasypt-spring-boot-de
mo-simple/target/jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/spring-boo
t-1.3.3.RELEASE.jar!/, jar:file:/U:/git/jasypt-spring-boot-samples-actuals/jasyp
t-spring-boot-demo-simple/target/jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar
!/lib/spring-context-4.2.4.RELEASE.jar!/, jar:file:/U:/git/jasypt-spring-boot-sa
mples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-spring-boot-demo-simp
le-0.1-SNAPSHOT.jar!/lib/spring-aop-4.2.4.RELEASE.jar!/, jar:file:/U:/git/jasypt
-spring-boot-samples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-spring
-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/aopalliance-1.0.jar!/, jar:file:/U:/git/
jasypt-spring-boot-samples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-
spring-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/spring-beans-4.2.4.RELEASE.jar!/,
jar:file:/U:/git/jasypt-spring-boot-samples-actuals/jasypt-spring-boot-demo-simp
le/target/jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/spring-expression
-4.2.4.RELEASE.jar!/, jar:file:/U:/git/jasypt-spring-boot-samples-actuals/jasypt
-spring-boot-demo-simple/target/jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar!
/lib/spring-boot-autoconfigure-1.3.3.RELEASE.jar!/, jar:file:/U:/git/jasypt-spri
ng-boot-samples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-spring-boot
-demo-simple-0.1-SNAPSHOT.jar!/lib/spring-boot-starter-logging-1.3.3.RELEASE.jar
!/, jar:file:/U:/git/jasypt-spring-boot-samples-actuals/jasypt-spring-boot-demo-
simple/target/jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/logback-class
ic-1.1.5.jar!/, jar:file:/U:/git/jasypt-spring-boot-samples-actuals/jasypt-sprin
g-boot-demo-simple/target/jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/l
ogback-core-1.1.5.jar!/, jar:file:/U:/git/jasypt-spring-boot-samples-actuals/jas
ypt-spring-boot-demo-simple/target/jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.j
ar!/lib/slf4j-api-1.7.16.jar!/, jar:file:/U:/git/jasypt-spring-boot-samples-actu
als/jasypt-spring-boot-demo-simple/target/jasypt-spring-boot-demo-simple-0.1-SNA
PSHOT.jar!/lib/jcl-over-slf4j-1.7.16.jar!/, jar:file:/U:/git/jasypt-spring-boot-
samples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-spring-boot-demo-si
mple-0.1-SNAPSHOT.jar!/lib/jul-to-slf4j-1.7.16.jar!/, jar:file:/U:/git/jasypt-sp
ring-boot-samples-actuals/jasypt-spring-boot-demo-simple/target/jasypt-spring-bo
ot-demo-simple-0.1-SNAPSHOT.jar!/lib/log4j-over-slf4j-1.7.16.jar!/, jar:file:/U:
/git/jasypt-spring-boot-samples-actuals/jasypt-spring-boot-demo-simple/target/ja
sypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/spring-core-4.2.4.RELEASE.jar
!/, jar:file:/U:/git/jasypt-spring-boot-samples-actuals/jasypt-spring-boot-demo-
simple/target/jasypt-spring-boot-demo-simple-0.1-SNAPSHOT.jar!/lib/snakeyaml-1.1
6.jar!/]
2016-10-13 11:07:12.281 DEBUG 14724 --- [ main] eEncryptablePropertySo
urcesPostProcessor : Application Event Raised: ApplicationFailedEvent
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.Invocat
ionTargetException
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
.java:62)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
.java:54)
... 1 more
Caused by: org.springframework.context.ApplicationContextException: Exception Cr
eating PropertySource; nested exception is java.lang.IllegalArgumentException: P
roperty source name must contain at least one character
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.lo
adEncryptablePropertySource(EncryptablePropertySourcesInitializer.java:71)
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.la
mbda$postProcessBeanFactory$0(EncryptablePropertySourcesInitializer.java:58)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Sour
ce)
at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
at java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Sour
ce)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemain
ing(Unknown Source)
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Unknown S
ource)
at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.po
stProcessBeanFactory(EncryptablePropertySourcesInitializer.java:58)
at org.springframework.context.support.PostProcessorRegistrationDelegate
.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)
at org.springframework.context.support.PostProcessorRegistrationDelegate
.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)
at org.springframework.context.support.AbstractApplicationContext.invoke
BeanFactoryPostProcessors(AbstractApplicationContext.java:678)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:520)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.
java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(Sp
ringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java
:307)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringA
pplicationBuilder.java:134)
at demo.SimpleDemoApplication.main(SimpleDemoApplication.java:42)
... 6 more
Caused by: java.lang.IllegalArgumentException: Property source name must contain
at least one character
at org.springframework.util.Assert.hasText(Assert.java:168)
at org.springframework.core.env.PropertySource.<init>(PropertySource.jav
a:71)
at org.springframework.core.env.PropertySource.<init>(PropertySource.jav
a:85)
at org.springframework.core.env.EnumerablePropertySource.<init>(Enumerab
lePropertySource.java:51)
at org.springframework.core.env.CompositePropertySource.<init>(Composite
PropertySource.java:52)
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.cr
eatePropertySource(EncryptablePropertySourcesInitializer.java:79)
at com.ulisesbocchio.jasyptspringboot.configuration.EncryptablePropertyS
ourcesInitializer$EncryptablePropertySourceAnnotationBeanFactoryPostProcessor.lo
adEncryptablePropertySource(EncryptablePropertySourcesInitializer.java:63)
... 32 more
U:\git\jasypt-spring-boot-samples-actuals\jasypt-spring-boot-demo-simple\target>
from jasypt-spring-boot-samples.
Hi UB,
So i figured out the root cause of my first error. The "name" attribute was mandatory for @EncryptablePropertySource
annotation. So added the "name" attribute name="classpath:encrypted.properties"
.
Full change as below.
@EncryptablePropertySources({@EncryptablePropertySource(name="classpath:encrypted.properties", value="classpath:encrypted.properties"),
@EncryptablePropertySource(name = "IgnoredResource_FileDoesNotExist", value = "classpath:does_not_exists.properties", ignoreResourceNotFound = true)})
As per documentation, the "name" attribute wasn't mentioned as mandatory. Please advise.
Now, i'm getting a different error. PFB.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String demo.MyService.secret; nested exception is org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
at demo.SimpleDemoApplication.main(SimpleDemoApplication.java:42)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String demo.MyService.secret; nested exception is org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 15 common frames omitted
**Caused by: org.jasypt.exceptions.EncryptionOperationNotPossibleException: null**
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:1055)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
at org.jasypt.encryption.pbe.PooledPBEStringEncryptor.decrypt(PooledPBEStringEncryptor.java:498)
at com.ulisesbocchio.jasyptspringboot.encryptor.LazyStringEncryptor.decrypt(LazyStringEncryptor.java:32)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:16)
at com.ulisesbocchio.jasyptspringboot.wrapper.EncryptableEnumerablePropertySourceWrapper.getProperty(EncryptableEnumerablePropertySourceWrapper.java:26)
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:84)
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:60)
at org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:531)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$1.getProperty(PropertySourcesPlaceholderConfigurer.java:132)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$1.getProperty(PropertySourcesPlaceholderConfigurer.java:129)
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:84)
at org.springframework.core.env.PropertySourcesPropertyResolver.getPropertyAsRawString(PropertySourcesPropertyResolver.java:70)
at org.springframework.core.env.AbstractPropertyResolver$1.resolvePlaceholder(AbstractPropertyResolver.java:207)
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:147)
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:204)
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:178)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:172)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:808)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1027)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 17 common frames omitted
Can you please help me out?
Thanks in advance.
Madhu.
from jasypt-spring-boot-samples.
The "name" attribute was mandatory for
EncryptablePropertySource annotation. So added the "name" attribute
name="classpath:encrypted.properties".
that in fact is a bug, I fixed it, thanks for catching it.
from jasypt-spring-boot-samples.
EncryptionOperationNotPossibleException
basically means that you're trying to decrypt a property with a password different than the one used to encrypt the property.
The password for the demo app must be password
in order to decrypt the properties present. You can't mix, all properties need to be encrypted with the same password.
from jasypt-spring-boot-samples.
chupacabras :)
The "name" attribute was mandatory for
EncryptablePropertySource annotation. So added the "name" attribute
name="classpath:encrypted.properties".that in fact is a bug, I fixed it, thanks for catching it.
Still, the "name" attribute issue isn't resolved. Did mvn clean install
.
Can you please double confirm from your end?
from jasypt-spring-boot-samples.
I fixed it on the code but it isn't released yet, you'd have to download the latest code from jasypt-spring-boot and build it. Then use the snapshot dependency on the sample project
from jasypt-spring-boot-samples.
Let me know once it is released. Will add the "name" attribute temporarily.
As per your documentation, if there is @SpringBootApplication
or @EnableAutoConfiguration
then we can use jasypt-spring-boot-starter
.
But when I remove
@EncryptablePropertySources({@EncryptablePropertySource(name="classpath:encrypted.properties", value="classpath:encrypted.properties"),
@EncryptablePropertySource(name = "IgnoredResource_FileDoesNotExist", value = "classpath:does_not_exists.properties", ignoreResourceNotFound = true)})
then, I get the below error.
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'secret.property' in string value "${secret.property}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:204)
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:178)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:172)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:808)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1027)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 17 common frames omitted
Is @EncryptablePropertySources
mandatory?
Please advise.
from jasypt-spring-boot-samples.
The starter jar allows you to avoid the @EnableEncryptableProperties
annotation. You don't really need @EncryptablePropertySources
either, you can just put your encrypted properties in the regular properties file application.properties
and you wouldn't need to add any special annotations. @EncryptablePropertySource
is just like PropertySource
, but is for sure encryptable. It exists for the purpose of someone not wanting to use neither the starter jar nor the @EnableEncryptableProperties
, in which case the target of the @EncryptablePropertySource
would be the only file supporting encryption. Basically, when you enable encryptable properties globally (with @EnableEncryptableProperties
or the starter jar) you don't need @EncryptablePropertySource
, it's redundant, since every property source will become encryptable regardless.
from jasypt-spring-boot-samples.
Got it. Had to rename encrypted.properties to application.properties. Thanks
Let me know once your changes are released.
from jasypt-spring-boot-samples.
Hi UB,
Today, I tried to integrate your encryption module into my webapp. But, only the un-encrypted value was printed in the console.
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableAutoConfiguration(exclude=DataSourceAutoConfiguration.class)
@EnableConfigurationProperties
@ImportResource("classpath:config-spring.xml")
@ComponentScan(basePackages = {"com.test"})
public class Application implements CommandLineRunner{
Do I need to have any additional configuration?
All I did was to add jasypt-spring-boot-starter (1.8) in my pom.xml
Please advise.
Thanks in advance.
Madhu.
from jasypt-spring-boot-samples.
from jasypt-spring-boot-samples.
Do you have a webapp example?
from jasypt-spring-boot-samples.
Yup there's a tomcat demo, but it doesn't really matter what it is. What is that xml config your loading??
from jasypt-spring-boot-samples.
I added another demo with a vanilla Spring Boot Web Application: https://github.com/ulisesbocchio/jasypt-spring-boot-samples/tree/master/jasypt-spring-boot-demo-web
Using the starter jar. That should help you figure out how to configure your project
from jasypt-spring-boot-samples.
1.9 was released with the fix for the @EncryptablePropertySource
name issue
from jasypt-spring-boot-samples.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jasypt-spring-boot-samples.