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

Error starting Tomcat / Cannot load driver class: org.mariadb.jdbc.Driver #788

Closed
felixlberg opened this issue Aug 22, 2019 · 4 comments
Closed
Labels
status: new Initial state for every issue / pullrequest type: bug Something's wrong

Comments

@felixlberg
Copy link

Describe the bug
Alle getesteten Versionen ( 2.42.0-2.44.2 ),
failen mit folgenden Error Cannot load driver class: org.mariadb.jdbc.Driver

Ich habe die folgenden Einstellungen in application.properties verwendet:

spring.datasource.url=jdbc:mariadb://localhost:3308/urlaubsverwaltung
spring.datasource.username=urlaubsverwaltung
spring.datasource.password=PASSWORT
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
# see https://stackoverflow.com/questions/32968527/hibernate-sequence-doesnt-exist
spring.jpa.properties.hibernate.id.new_generator_mappings=false
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.ddl-auto=none

spring.liquibase.change-log=classpath:/dbchangelogs/changelogmaster.xml
spring.liquibase.contexts=p

Ebenfalls ausprobiert mit:

spring.datasource.url=jdbc:mariadb://localhost:3308/urlaubsverwaltung
spring.datasource.username=urlaubsverwaltung
spring.datasource.password=PASSWORT
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver

Ich habe Ebenfalls versucht die Anwendung ohne application.properties Datei im Anwendungsordner zu starten:

java -jar -Dspring.datasource.password=PASSWORT urlaubsverwaltung-2.44.2.war

Leider tritt immer der genannte Fehler auf, hier nochmal der Startprozeß im Detail:

2019-08-22 14:08:37.350  INFO 44487 --- [           main] o.s.u.UrlaubsverwaltungApplication       : Starting UrlaubsverwaltungApplication v2.43.0 on th-holiday01 with PID 44487 (/opt/urlaubsverwaltung/urlaubsverwaltung-2.43.0.war started by hldadmin in /opt/urlaubsverwaltung)
2019-08-22 14:08:37.358  INFO 44487 --- [           main] o.s.u.UrlaubsverwaltungApplication       : No active profile set, falling back to default profiles: default
2019-08-22 14:08:40.416  INFO 44487 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-08-22 14:08:40.740  INFO 44487 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 312ms. Found 14 repository interfaces.
2019-08-22 14:08:41.749  INFO 44487 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$28d96513] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-22 14:08:42.320  INFO 44487 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-08-22 14:08:42.372  INFO 44487 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-08-22 14:08:42.373  INFO 44487 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-08-22 14:08:42.387  INFO 44487 --- [           main] 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: [/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]
2019-08-22 14:08:46.231  INFO 44487 --- [           main] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-08-22 14:08:46.745  INFO 44487 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-08-22 14:08:46.745  INFO 44487 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 9282 ms
2019-08-22 14:08:47.217  INFO 44487 --- [           main] o.s.l.c.support.AbstractContextSource    : Property 'userDn' not set - anonymous context will be used for read-write operations
2019-08-22 14:08:47.318 ERROR 44487 --- [           main] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration': 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 java.lang.IllegalStateException: Cannot load driver class: org.mariadb.jdbc.Driver
2019-08-22 14:08:47.360  INFO 44487 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-08-22 14:08:47.379  WARN 44487 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2019-08-22 14:08:47.403  INFO 44487 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-08-22 14:08:47.418 ERROR 44487 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:157) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.synyx.urlaubsverwaltung.UrlaubsverwaltungApplication.main(UrlaubsverwaltungApplication.java:22) ~[classes!/:2.43.0]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[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:566) ~[na:na]
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[urlaubsverwaltung-2.43.0.war:2.43.0]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[urlaubsverwaltung-2.43.0.war:2.43.0]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[urlaubsverwaltung-2.43.0.war:2.43.0]
	at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58) ~[urlaubsverwaltung-2.43.0.war:2.43.0]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:125) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:415) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
	... 16 common frames omitted

Was ist hier Schiefgelaufen, könnt ihr mir dabei weiterhelfen ?

@felixlberg felixlberg added status: new Initial state for every issue / pullrequest type: bug Something's wrong labels Aug 22, 2019
@derTobsch
Copy link
Collaborator

Hey @felixlberg,
die 2.x Version läuft nicht mit der mariadb sondern mit mysql. Bitte nehme also den mysql treiber.

Siehe https://github.com/synyx/urlaubsverwaltung/blob/v2.x/src/main/resources/application.properties#L10

@felixlberg
Copy link
Author

Besten Dank!

Ich habe nun zu mysql gewechselt und die Einstellungen gemäß der Vorgabe angepaßt:

spring.datasource.url=jdbc:mysql://localhost:3308/urlaubsverwaltung?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe/Berlin
spring.datasource.username=urlaubsverwaltung
spring.datasource.password=PASSWORT
spring.datasource.tomcat.testOnBorrow=true
spring.datasource.tomcat.validationQuery=SELECT 1

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
# see https://stackoverflow.com/questions/32968527/hibernate-sequence-doesnt-exist
spring.jpa.properties.hibernate.id.new_generator_mappings=false
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.ddl-auto=none

spring.liquibase.change-log=classpath:/dbchangelogs/changelogmaster.xml
spring.liquibase.contexts=p

Jetzt bekomme ich allerdings folgenden Error:

2019-08-22 15:17:01.002 ERROR 46923 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

Was könnte das sein ?

@derTobsch
Copy link
Collaborator

Naja was sagt denn die Fehlernachricht?

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

Er sagt, dass die Datenbank nicht gefunden wird. Läuft denn eine Datenbank auf localhost auf dem Port 3306 wie in deiner Konfiguration beschrieben??

@felixlberg
Copy link
Author

Vielen Dank !!!

Mein Fehler ich hatte den falschen port angegeben...

Die Urlaubsverwaltung läuft nun 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: new Initial state for every issue / pullrequest type: bug Something's wrong
Projects
None yet
Development

No branches or pull requests

2 participants