Uploaded image for project: 'Commons Betwixt'
  1. Commons Betwixt
  2. BETWIXT-57

Class loader problem in JBoss version 4.0.4GA

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • None
    • None
    • None
    • JBoss application server version 4.0.4GA. Probably affects most versions of JBoss

    Description

      When using betwixt in a JBoss application, "Class not found" exceptions get thrown when Class.forName methods are called in classes org.apache.commons.betwixt.digester.ElementRule and org.apache.commons.betwixt.digester.ClassRule. Specifically the Class.forName method uses the system class loader to load classes and in JBoss the classpath normally does not contain the application jar files. The fix is very simple. The Class.forName method calls in both the classes were replaced with the following code lines in ElementRule and similar changes were made in ClassRule as well. This fix ensures that the appropriate class loader is used for loading classes and is similar to the fix made in log4j.

      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      if (loader == null)

      { loader = Class.forName(implementationClass).getClassLoader(); //Class clazz = Class.forName(implementationClass); }

      Class clazz = loader.loadClass(implementationClass);
      descriptor.setImplementationClass(clazz);

      Attachments

        Activity

          People

            Unassigned Unassigned
            surjitsen Surjit Sen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: