First, I'm assuming that this code is running in the same web app as jForum and not a different one..
If so, the problem with the initial call to a Jforum page may be because the CacheEngine and database engine are initialized in the JForum
Servlet init method. This servlet processes all *.page requests.
If I remember correctly, the
J2EE Specs are kind of vague on when application engines are required to call the init method. There is a load-on-startup web.xml parameter but this may not be honored or the container may be letting requests come through before everything is initialized. Or worse, not calling the init method until the first call to the jForum servlet is made.
The DB problem (and maybe the init problem) may be due to the fact that the JForum servlet service method does a check to see if the DB is initialized and re-initializes it if it isn't. I'm not sure, but I guess that code is being called every time to fix similar problems.
[originally posted on jforum.net by monroe]