Spring boot 2.6.0 'integrationDataSourceInitializer' throws is java.lang.IllegalStateException: Unable to detect database type
See original GitHub issueI am observing the following error for Sybase database after upgrading Spring boot version from 2.4.5 to 2.6.0.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer]: Factory method ‘integrationDataSourceInitializer’ threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
application.yaml
spring:
jpa:
hibernate:
ddl-auto: none
generate-ddl: false
naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
databasePlatform: org.hibernate.dialect.SybaseDialect
database: sybase
datasource:
url: jdbc:sybase:Tds:_host_:_port_/_database_
driverClassName: com.sybase.jdbc4.jdbc.SybDriver
username: _username_
password: _password_
Exception stack trace:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-03 14:38:12.106 ERROR 25344 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'integrationDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration$IntegrationJdbcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer]: Factory method 'integrationDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.13.jar!/:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.13.jar!/:5.3.13]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.13.jar!/:5.3.13]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.0.jar!/:2.6.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-2.6.0.jar!/:2.6.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.6.0.jar!/:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.0.jar!/:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.0.jar!/:2.6.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.0.jar!/:2.6.0]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer]: Factory method 'integrationDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.13.jar!/:5.3.13]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.13.jar!/:5.3.13]
... 29 common frames omitted
Caused by: java.lang.IllegalStateException: Unable to detect database type
at org.springframework.util.Assert.state(Assert.java:76) ~[spring-core-5.3.13.jar!/:5.3.13]
at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.determinePlatform(PlatformPlaceholderDatabaseDriverResolver.java:114) ~[spring-boot-2.6.0.jar!/:2.6.0]
at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.resolveAll(PlatformPlaceholderDatabaseDriverResolver.java:103) ~[spring-boot-2.6.0.jar!/:2.6.0]
at org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer.getSettings(IntegrationDataSourceScriptDatabaseInitializer.java:70) ~[spring-boot-autoconfigure-2.6.0.jar!/:2.6.0]
at org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer.<init>(IntegrationDataSourceScriptDatabaseInitializer.java:43) ~[spring-boot-autoconfigure-2.6.0.jar!/:2.6.0]
at org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJdbcConfiguration.integrationDataSourceInitializer(IntegrationAutoConfiguration.java:244) ~[spring-boot-autoconfigure-2.6.0.jar!/:2.6.0]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.13.jar!/:5.3.13]
... 30 common frames omitted
Issue Analytics
- State:
- Created 2 years ago
- Comments:26 (12 by maintainers)
Top Results From Across the Web
Unable to detect database type - spring boot - Stack Overflow
I was debugging BatchDatabaseInitializer , where error came from, and when it calls JdbcUtils.commonDatabaseName(...) , "Microsoft SQL Server" ...
Read more >Spring Boot - Cannot determine embedded database driver ...
Cannot determine embedded database driver class for database type NONE. This error comes when you don't have a DataSource configured for your ...
Read more >Using Postgres: 'Unable to detect database type'.
Caused by: java.lang.IllegalStateException: Unable to detect database type at org.springframework.util.Assert.state(Assert.java:76).
Read more >[Solved]-Unable to detect database type-Springboot
Add this in your Application file within the main function. @SpringBootApplication( exclude = { BatchAutoConfiguration. · Try spring.batch. · You need to properly ......
Read more >error creating bean with name 'scriptdatasourceinitializer'
spring-projects/spring-bootSpring boot 2.6.0 'integrationDataSourceInitializer' throws is java.lang.IllegalStateException: Unable to detect database type# ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve opened #28932 and #28931 for problems that are related to this. Once those have been fixed, we’ll review this problem again and see what, if anything, more we need to do.
@wilkinsona Yes, it does look like a different problem as the exception and message are different. But I think the core problem could be a failure to detect and set the configs specified by the application properties file, because I tried to set several properties (reading and following the doc) for preventing Hibernate from initializing database and it didn’t make any difference.
The doc says that Hibernate takes different default values depending on schema manager detection and on whether database is embedded, and it looks at Connection type and JDBC URL. As the URL is the main difference between QA and Local config properties here, I think it could be impacting or overriding some configs.
There are many other projects here with similar properties in their QA and Prod environments, but with version 2.3.x, and they don’t present this problem! The supposed failure could be the cause for both database’s type detection and schema script detection failures.
Nevertheless I’ll double check the environment variables.