i have the driver dependency in the POM.xml and i am using maven shade plugin to create an Uber Jar. i do see the driver dependency correctly listed in the JAR file. Jar runs fine in intellij but on google dataproc cluster it fails with class not found error.
POM file with dependency:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0.0</version>
</dependency>
Jar listing the dependency classes are in the JAR
>target % jar tf app.jar | grep SQLServerDriver
com/microsoft/sqlserver/jdbc/SQLServerDriver.class
com/microsoft/sqlserver/jdbc/SQLServerDriverBooleanProperty.class
com/microsoft/sqlserver/jdbc/SQLServerDriverIntProperty.class
com/microsoft/sqlserver/jdbc/SQLServerDriverPropertyInfo.class
com/microsoft/sqlserver/jdbc/SQLServerDriverStringProperty.class
Here is my Application YAML file which has the driver listed
datasource:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc-url:"jdbc:sqlserver://sqlserver.dev.db.xyz.com;databaseName=db01;multiSubnetFailover=true"
username: "sa_user"
Below is the full error message:
24/11/29 15:48:38 WARN org.springframework.context.annotation.AnnotationConfigApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'dataSource': Could not bind properties to 'DataSource' : prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource' to javax.sql.DataSource
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
Property: spring.datasource.driver-class-name
Value: "com.microsoft.sqlserver.jdbc.SQLServerDriver"
Origin: class path resource [application.yaml] from app.jar - 11:24
Reason: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
Action:
Update your application's configuration