So, I have had a working Tomcat JDBC session storage solution for some time. I deployed what I consider to be an unrelated change (and I rolled back to previous war and the new issue still exists).
The problem
I can reproduce the problem like this
systemctl restart tomcat
- wait for wars to load, manager to respond etc
- access web app page that fetches for session, syserr:
java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.catalina.session.JDBCStore.open(JDBCStore.java:955)
(this part of apache's JDBCStore imple tries to load db driver using class name)
- I keep accessing the web page -> same error to syserr
- I keep doing this for a minute or so
- Error suddenly no longer appears and session storage works as it should (persists new sessions all the way to db correctly, fetches sessions since prev restart correctly)
What I have tried
- I have checked context.xml (that has the JDBCStore configuration) has not been changed by updates (and surely it is ok since the app does work eventually)
- I have double checked jdbc driver is in tomcat/lib folder, has permissions etc (and surely it is since the app does work eventually)
- I have tried to think of any change on the server that might cause this but I'm drawing blank
- Killing Tomcat with
kill -9 <pid>
instead ofsystemctl restart
does not make a difference - Stopping Tomcat, waiting for ~3 minutes and starting up: no difference, still have to wait ~1 minute before session storage works
What I suspect it that somehow JDBCStore (which is "internal Tomcat stuff", not part of my app) can not load the driver with Class.forName, but some other app/connection poll that I have running on the same Tomcat succeeds, and after that JDBCStore also works. What I don't know is why this has come up now but not lets say a month ago. In any case, any hints would be nice.
Tomcat8
openjdk version "1.8.0_265"
RHEL 7.9