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

Support option to disable external access during CDS training #924

Open
making opened this issue Nov 5, 2024 · 1 comment
Open

Support option to disable external access during CDS training #924

making opened this issue Nov 5, 2024 · 1 comment
Assignees
Labels
in: event publication registry Event publication registry meta: investigating Stuff that needs more investigation type: improvement Minor improvements

Comments

@making
Copy link
Member

making commented Nov 5, 2024

The following error occurred during CDS training in an app that uses spring-modulith-starter-jdbc (1.2).
This seems to be caused by opening a connection at runtime to determine the DatabaseType.
I haven't tried it with other modules, but I would like them to support CDS builds by adding an option such as -Dspring.flyway.enabled=false that does not make an external connection during CDS training, or, in the case of JDBC, an option to specify the DatabaseType statically.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseType' defined in class path resource [org/springframework/modulith/events/jdbc/JdbcEventPublicationAutoConfiguration.class]: Failed to instantiate [org.springframework.modulith.events.jdbc.DatabaseType]: Factory method 'databaseType' threw exception with message: Unsupported database type: UNKNOWN
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1355)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1185)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda-zsh(AbstractBeanFactory.java:337)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:971)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
	at am.ik.note.NoteApiApplication.main(NoteApiApplication.java:10)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.modulith.events.jdbc.DatabaseType]: Factory method 'databaseType' threw exception with message: Unsupported database type: UNKNOWN
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:178)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
	... 19 more
Caused by: java.lang.IllegalArgumentException: Unsupported database type: UNKNOWN
	at org.springframework.modulith.events.jdbc.DatabaseType.lambda(DatabaseType.java:54)
	at java.base/java.util.Optional.orElseThrow(Unknown Source)
	at org.springframework.modulith.events.jdbc.DatabaseType.from(DatabaseType.java:54)
	at org.springframework.modulith.events.jdbc.JdbcEventPublicationAutoConfiguration.databaseType(JdbcEventPublicationAutoConfiguration.java:45)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146)
	... 20 more

The current workaround is to add -Dspring.autoconfigure.exclude=org.springframework.modulith.events.jdbc.JdbcEventPublicationAutoConfiguration during training.

@odrotbohm odrotbohm self-assigned this Nov 13, 2024
@odrotbohm odrotbohm added in: event publication registry Event publication registry type: improvement Minor improvements meta: investigating Stuff that needs more investigation labels Nov 13, 2024
@odrotbohm
Copy link
Member

Taking this to the team to decide about the best way forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: event publication registry Event publication registry meta: investigating Stuff that needs more investigation type: improvement Minor improvements
Projects
None yet
Development

No branches or pull requests

2 participants