Page 1 of 1

Hint if you wanna upgrade to tomcat 8.0.x

PostPosted:Fri Sep 12, 2014 2:02 pm
by Catscratch
Hi,

I'm using OpenKM 6.3 on Tomcat 8.0.9 and a strange error costs me several hours of time until I noticed the reason.

If you want to run OpenKM in Tomcat 8.0.x you will get the following exception on startup:
Code: Select all
2014-09-12 15:28:55,986 [localhost-startStop-1] INFO  com.openkm.servlet.RepositoryStartupServlet- *** Initialize property groups... ***
2014-09-12 15:28:55,990 [localhost-startStop-1] INFO  com.openkm.util.FormUtils$LocalResolver- new LocalResolver(null)
2014-09-12 15:28:55,991 [localhost-startStop-1] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]- StandardWrapper.Throwable
java.lang.ExceptionInInitializerError
	at com.openkm.servlet.RepositoryStartupServlet.init(RepositoryStartupServlet.java:110)
	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1241)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1154)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4932)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5218)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
	at java.io.File.<init>(File.java:277)
	at com.openkm.util.FormUtils$LocalResolver.<init>(FormUtils.java:845)
	at com.openkm.util.FormUtils.<clinit>(FormUtils.java:73)
	... 14 more
Long story short. There was a change in the servlet API in tomcat.

The method
Code: Select all
String javax.servlet.ServletContext.getRealPath(String path)
does no longer allow passing a parameter without a leading "/". So you have to correct the OpenKM sources in the Config.java on line 578 and 582 to look like the following.
Code: Select all
578: DTD_BASE = sc.getRealPath("/WEB-INF/classes/dtd");
582: LANG_PROFILES_BASE = sc.getRealPath("/WEB-INF/classes/lang-profiles");
Without a leading "/" the ServletContext will return null and then the whole OpenKM startup process fails.

So if you plan to upgrade to a newer tomcat version, keep this in mind.

Re: Hint if you wanna upgrade to tomcat 8.0.x

PostPosted:Mon Sep 15, 2014 12:30 pm
by pavila
Thanks for the info. This error is quite weird! I'm not sure if it's a Tomcat 8 issue.

I've added a couple of comments to remember it when needed.