org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class in JBoss EAP
Issue
- Spring Boot 3 application failing to start looking for datasource
The application.properties specifies the jndi lookup for the datasource that is defined in the EAP 8 datasources subsystem:
spring.datasource.jndi-name=java:jboss/datasources/ExampleDS
The Spring Boot application code that is getting the datasource looks like:
@Primary
@Bean(name="exampleDatasource")
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource datasource(@Qualifier("exampleProperties") DataSourceProperties properties){
return properties.initializeDataSourceBuilder().build();
}
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'datasource' threw exception with message: Failed to determine a suitable driver class
at deployment.ROOT.war//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)
at deployment.ROOT.war//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:647)
... 56 more
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
at deployment.ROOT.war//org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:186)
at deployment.ROOT.war//org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:125)
at deployment.ROOT.war//com.redhat.examples.ExampleDatasourceConfiguration.datasource(ExampleDatasourceConfiguration.java:43)
at deployment.ROOT.war//com.redhat.examples.ExampleDatasourceConfiguration$$SpringCGLIB$$0.CGLIB$datasource$0(<generated>)
at deployment.ROOT.war//com.redhat.examples.ExampleDatasourceConfiguration$$SpringCGLIB$$FastClass$$1.invoke(<generated>)
at deployment.ROOT.war//org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258)
at deployment.ROOT.war//org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at deployment.ROOT.war//com.redhat.examples.ExampleDatasourceConfiguration$$SpringCGLIB$$0.datasource(<generated>)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at deployment.ROOT.war//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
... 57 more
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 8.0
- Spring Boot 3
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.