Affects Version/s: None
Fix Version/s: None
Problem with ClassNotFoundException for custom format class configured in click.xml (the same applies if a custom error page is configured for instance).
This exception occurs for
private void loadFormatClass(Element rootElm)
formatClass = Class.forName(classname);
To reproduce setup Tomcat directories like:
- - lib
- myapp/WEB-INF/lib (empty)
When I debugged this issue I found, that when the click servlet is inited Class.forName(classname) uses Tomcat's StandardClassLoader which searches for the class only in tomcat\shared\classes etc. but NOT in WEB-INF\classes.
One workaround to solve this issue would be to copy the click....jar's to the WEB-INF/lib directory - yes then the problem does not occur, probably because the click servlet is loaded by the WebAppClassloader (sorry I had not time to investigate it further). However in our environment we store the libs in a shared location.
The fix is to use the following code instead (this worked):
// get the context classloader e.g. WebappClassLoader
ClassLoader webCl = Thread.currentThread().getContextClassLoader();
formatClass = Class.forName(classname, true, webCl);
NOTE: There are 2 occurences of Class.loadClass in ClickApp to fix.
Please review and fix this for the next release.