Uploaded image for project: 'Click'
  1. Click
  2. CLK-256

ClassNotFoundException in StandardClassLoader (Tomcat)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • None
    • core
    • None
    • 1.4RC1
      Tomcat 5.0.16

    Description

      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:

      • shared
      • - lib
        click-1.4RC1.jar
        click-extracts
      • webapps
          • myapp/WEB-INF/classes/com.mycorp.com/CustomFormat.class
            • 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.

      Thx.

      Attachments

        Activity

          People

            medgar Malcolm Edgar
            harry.wissiak@audatex.ch harryw
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: