gs-accessing-data-mysql: Example fails to start with HikariDataSource related error

Hi!

First of all, thank you very much for all the work you’re putting in the examples and docs: It really makes the difference when learning new topics! 🥇

When running the example in the ./complete/ directory, with the only changed being done on my side is the update of the username/pass for the database i’m getting the following error: Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource

See the complete start log below:

2018-04-16 09:15:00.638  INFO 33768 --- [           main] hello.Application                        : Starting Application on MW7IF7J13IEI10 with PID 33768 (C:\Users\sergio.f.gonzalez\git\spring-examples-repo\complete\target\classes started by sergio.f.gonzalez in C:\Users\sergio.f.gonzalez\git\spring-examples-repo\complete)
2018-04-16 09:15:00.641  INFO 33768 --- [           main] hello.Application                        : No active profile set, falling back to default profiles: default
2018-04-16 09:15:00.678  INFO 33768 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@222114ba: startup date [Mon Apr 16 09:15:00 CEST 2018]; root of context hierarchy
2018-04-16 09:15:01.451  INFO 33768 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$e0ae4b3f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-04-16 09:15:01.675  INFO 33768 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-04-16 09:15:01.699  INFO 33768 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-04-16 09:15:01.700  INFO 33768 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-04-16 09:15:01.703  INFO 33768 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\dev-sw\jdk1.8.0_162\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_162/bin/server;C:/Program Files/Java/jre1.8.0_162/bin;C:/Program Files/Java/jre1.8.0_162/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\dev-sw\apache-maven-3.5.3\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\dev-sw\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\dev-sw\Vagrant\bin;C:\Users\sergio.f.gonzalez\Downloads\~delete.me~\ec2-api-tools\ec2-api-tools-1.7.5.1\bin;C:\Program Files\OpenVPN\bin;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\GNU\GnuPG\pub;C:\Program Files\Amazon\AWSCLI\;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\;C:\Users\sergio.f.gonzalez\AppData\Local\Microsoft\WindowsApps;C:\dev-sw\Git\cmd;;C:\dev-sw\spring-tool-suite\spring-tool-suite-3.9.2.RELEASE-e4.7.2-win32-x86_64\sts-bundle\sts-3.9.2.RELEASE;;.]
2018-04-16 09:15:01.797  INFO 33768 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-04-16 09:15:01.797  INFO 33768 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1120 ms
2018-04-16 09:15:01.907  INFO 33768 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-04-16 09:15:01.911  INFO 33768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-04-16 09:15:01.912  INFO 33768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-04-16 09:15:01.912  INFO 33768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-04-16 09:15:01.912  INFO 33768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-04-16 09:15:01.967 ERROR 33768 --- [           main] com.zaxxer.hikari.HikariConfig           : Failed to load driver class com.mysql.jdbc.Driver from HikariConfig class classloader sun.misc.Launcher$AppClassLoader@764c12b6
2018-04-16 09:15:01.970  WARN 33768 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource
2018-04-16 09:15:01.972  INFO 33768 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-04-16 09:15:01.985  INFO 33768 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-04-16 09:15:01.989 ERROR 33768 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:

    Property: driverclassname
    Value: com.mysql.jdbc.Driver
    Origin: "driverClassName" from property source "source"
    Reason: Unable to set value for property driver-class-name

Action:

Update your application's configuration

If i downgrade the version of the spring-boot-starter-parent to 2.0.0.RELEASE the application works without problems.

Thank you very much!

Sergio

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 19

Most upvoted comments

The problem is MySQL binary is not in classpath yet. You can add a MySQL connection string into the application.properties file without add MySQL driver dependency to reproduce the issue. I’m using initial but I don’t have that problem anymore

remove .driverClassName from data source builder instead add dependency of driver in pom also no need of spring-boot-starter-data-jdbc HikariDataSource will pick from there

I solved this issue by deleting the m2 folder of MVN and re-caching all dependencies.

this issue for me was caused by the version of mysql. all i had to do is add the version of mysql in pom.xml dependencies (in my case the verion is 8.0.25)

<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.25</version> </dependency>

make sure to reload the maven dependecies before your run

HikariDataSource is already included in the sample app (it is the default data source in Spring Boot 2). I would look at your Maven cache if I were you, to see if you can find the bad jar.