Setup fails with "No suitable driver found" when Tomcat started without database.properties
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
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
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.mdondevtells operators to rerun setup exactly this way ("To run setup again, delete/usr/local/tomcat/conf/database.propertiesand restart Tomcat").- A manual installation, where
conf/has nodatabase.propertiesuntil 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
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OWASP/SecurityShepherd
-
ci: integration-tests fail on Ubuntu 26 because /etc/init.d/mysql is removedPossibly taken @Md-Khursheed claimed this 2 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
OWASP/SecurityShepherd#1114 ·
Maintainers usually reply within 1 day
-
DirectObjectBankLogin holds a challenge-pool connection while bankForm() borrows a second onePossibly taken @utafrali claimed this 8 days ago. OpenBug Levels
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OWASP/SecurityShepherd#1063 · 1 comment ·
Maintainers usually reply within 1 day
-
Bug WebApp
Difficulty 1/5 Under an hour Newbie friendliness 78/100
OWASP/SecurityShepherd#996 ·
Maintainers usually reply within 1 day
-
index.jsp: CTF countdown never clears, malformed deletePlayers error HTML, debug alert on success messagesMay be free again @Sagar07Kr claimed this 9 days ago, and no pull request is open. OpenBug WebApp
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
OWASP/SecurityShepherd#995 · 1 comment ·
Maintainers usually reply within 1 day
-
[BUG] NoSQL Injection 1 only answers once per Tomcat run: the servlet closes the shared MongoClientPossibly taken A pull request linked to this issue is open or already merged. OpenBug Levels
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OWASP/SecurityShepherd#992 · 1 comment ·
Maintainers usually reply within 1 day
All issues in OWASP/SecurityShepherd
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Julow/Unexpected-Keyboard#1490 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Vakore/ZappierGames#275 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
unitycatalog/unitycatalog#2148 ·
Maintainers usually reply within 2 days
-
enhancement priority: low
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Riptide-Labs/riptide#1060 ·
Maintainers usually reply within 1 day
-
bug key bindings source editor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day