Setup fails with "No suitable driver found" when Tomcat started without database.properties

Open Beginner friendly
#1,082 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@HusainMain is already working on this.

Since Oct 29, 2026.

  • #1091 by @HusainMain — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, java, mariadb

Research direction

Read Setup.java around the Setup.doPost call to DriverManager.getConnection at line 219, then inspect the setup tests and how they load the JDBC driver. Add a test that runs setup without another component loading the driver first; done means setup accepts valid database settings and the test passes.

Written by the indexing model from the issue text.

Description

Bug Platform

Discovered during #1081.

The setup page fails with No suitable driver found when Tomcat started without a database.properties in conf/:

ERROR servlets.Setup - DB connection error: java.sql.SQLException: No suitable driver found for jdbc:mariadb://secshep_mariadb:3306/?useUnicode=true&character_set_server=utf8mb4&connectTimeout=5000

Steps to reproduce

On a Docker installation that has already been set up:

docker exec secshep_tomcat rm /usr/local/tomcat/conf/database.properties
docker compose restart web

Then submit the setup page with correct settings (with or without Fresh Database). It answers "Database Configuration Failed … No suitable driver found", every time.

Cause

Setup.doPost tests the submitted settings with DriverManager.getConnection (Setup.java:219) without loading the driver class first. Tomcat doesn't register JDBC drivers from WEB-INF/lib with DriverManager on its own, so the call only works if something else has loaded org.mariadb.jdbc.Driver already.

On a fresh Docker container that's the connection pool: the image ships a database.properties built from .env, so DatabaseLifecycleListener tries to create the HikariCP pool at startup, which loads the driver class, even though the connection itself fails. Without a database.properties at startup, nothing loads the driver.

Impact

  • docs/database-configuration.md on dev tells operators to rerun setup exactly this way ("To run setup again, delete /usr/local/tomcat/conf/database.properties and restart Tomcat").
  • A manual installation, where conf/ has no database.properties until setup writes one, would presumably fail its first setup the same way. Not tested.

Fix

Load the driver class (Class.forName(driverType)) before DriverManager.getConnection in Setup, with a test that runs setup with no driver loaded beforehand.

🤖 Generated with Claude Code

Dominant language
Java
Stars
1.5k
Forks
530
Avg merge
1d 1h
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OWASP/SecurityShepherd

All issues in OWASP/SecurityShepherd

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.