7

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

  1. systemctl restart tomcat
  2. wait for wars to load, manager to respond etc
  3. 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)

  1. I keep accessing the web page -> same error to syserr
  2. I keep doing this for a minute or so
  3. 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 of systemctl 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
Esko Piirainen
  • 1,296
  • 2
  • 14
  • 28

1 Answers1

0

If tomcat could not open a connection to the database it will throw NPE, check this commit that fixes it. Update your tomcat that will be released which includes this latest patch and you won't get the NPE.

But check why you are not able to connect to the database.

Vishrant
  • 15,456
  • 11
  • 71
  • 120