Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy-property-sources=true causes ClassCastException #369

Open
greenarr0w opened this issue Aug 30, 2023 · 1 comment
Open

proxy-property-sources=true causes ClassCastException #369

greenarr0w opened this issue Aug 30, 2023 · 1 comment

Comments

@greenarr0w
Copy link

Hello

I'm trying to use jasypt.encryptor.proxy-property-sources=true so that the PropertySources aren't wrapped, only proxied. We need this in our setup, because our internal framework has wrapped those PropertySources.

Versions:
jasypt-spring-boot-starter:3.0.5
org.springframework.boot:2.7.14

Now I'm getting the following ClassCastException. The exception happens with a plain spring boot app with the jasypt-spring-boot-starter (first I thought it has something to do with our setup, but it doesn't seem like it):

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'servletWebServerFactoryCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.class]: Unsatisfied dependency expressed through method 'servletWebServerFactoryCustomizer' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is java.lang.ClassCastException: class org.springframework.core.env.PropertiesPropertySource cannot be cast to class com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource (org.springframework.core.env.PropertiesPropertySource and com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource are in unnamed module of loader 'app')
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165) ~[spring-boot-2.7.14.jar:2.7.14]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.29.jar:5.3.29]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.14.jar:2.7.14]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[spring-boot-2.7.14.jar:2.7.14]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.14.jar:2.7.14]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.7.14.jar:2.7.14]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.7.14.jar:2.7.14]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.7.14.jar:2.7.14]
	at com.example.demo.DemoApplicationKt.main(DemoApplication.kt:13) ~[main/:na]
nested exception is java.lang.ClassCastException: class org.springframework.core.env.PropertiesPropertySource cannot be cast to class com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource 

Is this a known issue or is there a way to fix it?

Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@greenarr0w and others