Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cannot Load H2 Driver - Application Failing to Start #161

Open
muha6841 opened this issue Aug 22, 2024 · 0 comments
Open

Cannot Load H2 Driver - Application Failing to Start #161

muha6841 opened this issue Aug 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@muha6841
Copy link

Issue Summary
The BPN Discovery application fails to start due to an inability to load the H2 database driver.
Steps to Reproduce:
Checked out both the bpndiscovery-0.3.1 (latest) and bpndiscovery-0.2.3 (older) versions of the BPN Discovery repository.
Configured the application.properties file with the following settings:
properties
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console

  1. Rebuilt the project using mvn clean install and java -jar backend/target/bpn-discovery-backend-{current-version}.jar --spring.profiles.active=local.

Actual Results:
The application fails to start, and the following error is logged:
Caused by: java.lang.ClassNotFoundException: org.h2.Driver
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
...
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource' defined in class path resource
[org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]:
Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource'
threw exception with message: Cannot load driver class: org.h2.Driver
Expected Results:
The application should start successfully using the H2 in-memory database.
Attempts to Resolve:

  1. Verified that the H2 dependency is included in the pom.xml file:
    xml

    com.h2database
    h2
    2.1.210
    runtime
  2. Checked the application.properties file for correct configuration.
  3. Rebuilt the project to ensure dependencies are correctly resolved.
  4. Ran the application with debug enabled to gather more detailed logs.

Environment

  • Versions Tried: Checked out both thebpndiscovery-0.3.1(latest) andbpndiscovery-0.2.3` (older) versions of the BPN Discovery repository.
  • Java Version: 17.0.12
  • Spring Boot Version: 3.3.1
  • Operating System: Ubuntu 22.04.3 LTS (with Linux kernel 5.15.0-94-generic).
    Attachments:
    All the tests in the project run successfully, indicating that the unit and integration tests are passing. However, when I run the application, I encounter runtime errors related to the H2 database driver, which prevent the application from starting. The detailed error logs are attached below for reference.
test results Error1 Error11
@muha6841 muha6841 added the bug Something isn't working label Aug 22, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant