This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 199628 - java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.logging.LogFactory
Summary: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons...
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-22 20:09 UTC by mclaborn
Modified: 2011-09-06 14:35 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mclaborn 2011-06-22 20:09:17 UTC
Product Version = NetBeans IDE 7.0 (Build 201104080000)
Operating System = Linux version 2.6.35-28-generic running on amd64
Java; VM; Vendor = 1.6.0_24
Runtime = Java HotSpot(TM) 64-Bit Server VM 19.1-b02

Full stack trace below.  I get this when trying to open a descendent of JPanel in the GUI designer.  I originally had 

public class PanelSKUDisplay extends ProdCatSKUMaintPanel {
  private static Log log = LogFactory.getLog(PanelSKUDisplay.class);

and changed it to 

public class PanelSKUDisplay extends ProdCatSKUMaintPanel {
  private static Log log = Util.createLog(PanelSKUDisplay.class); 


to get around this error.  (See createLog method below the stack trace.)

I've seen this in a number of my GUI classes.



Caused: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.logging.LogFactory
	at com.csc.mm.prodcatskumaint.PanelSKUDisplay.<clinit>(PanelSKUDisplay.java:34)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:247)
	at org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:96)
	at org.netbeans.modules.form.FormUtils.loadClass(FormUtils.java:1463)
	at org.netbeans.modules.form.PersistenceObjectRegistry.loadClass(PersistenceObjectRegistry.java:98)
	at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:767)
	at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1007)
	at org.netbeans.modules.form.GandalfPersistenceManager.restoreComponent(GandalfPersistenceManager.java:873)
	at org.netbeans.modules.form.GandalfPersistenceManager.loadComponent(GandalfPersistenceManager.java:1007)
	at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:527)
	at org.netbeans.modules.form.GandalfPersistenceManager.loadForm(GandalfPersistenceManager.java:299)
	at org.netbeans.modules.form.FormEditor$3.run(FormEditor.java:337)
	at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:293)
	at org.openide.util.Mutex.doEventAccess(Mutex.java:1361)
	at org.openide.util.Mutex.readAccess(Mutex.java:320)
	at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:276)
	at org.netbeans.modules.form.FormEditor.loadFormData(FormEditor.java:334)
[catch] at org.netbeans.modules.form.FormEditor.loadFormDesigner(FormEditor.java:232)
	at org.netbeans.modules.form.FormDesigner.finishComponentShowing(FormDesigner.java:1932)
	at org.netbeans.modules.form.FormDesigner.access$1100(FormDesigner.java:107)
	at org.netbeans.modules.form.FormDesigner$PreLoadTask$1.run(FormDesigner.java:1897)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:603)
	at java.awt.EventQueue$1.run(EventQueue.java:601)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Error in loading component: [ProdCatSKUMaintPanel]->tabbedPaneSKU->pnlSKUDisplay
Cannot load component class com.csc.mm.prodcatskumaint.PanelSKUDisplay.
The component cannot be loaded.






  public static Log createLog(Class a_class) {
    Log l_log;
    if (a_class == null) {
      l_log = new DummyLog();
    } else {
      try {
        l_log = LogFactory.getLog(a_class);
      } catch(Throwable a_e1) {
        l_log = new DummyLog();
      }
    }
    return l_log;
  }
Comment 1 mclaborn 2011-06-22 20:55:57 UTC
Might be important that PanelSKUDisplay is not the class I was trying to open in the GUI editor.  PanelSKUDisplay is a component that is used in the Panel that I was trying to open.
Comment 2 Jan Stola 2011-09-06 14:22:02 UTC
I was able to reproduce problems with components that are using commons logging. Unfortunately, I was not able to obtain the same exception (i.e., NoClassDefFoundError). I got the following exception instead:

java.lang.IllegalAccessError: tried to access class org.apache.commons.logging.LogFactory$6 from class org.apache.commons.logging.LogFactory
  at org.apache.commons.logging.LogFactory.getSystemProperty
     (LogFactory.java:1558)
  at org.apache.commons.logging.LogFactory.initDiagnostics(LogFactory.java:1575)
  at org.apache.commons.logging.LogFactory.<clinit>(LogFactory.java:1817)
  at javaapplication8.LogPanel.<clinit>(LogPanel.java:15)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:264)
  at org.netbeans.modules.form.project.ClassPathUtils.loadClass
     (ClassPathUtils.java:100)
  at org.netbeans.modules.form.MetaComponentCreator.prepareClass0
     (MetaComponentCreator.java:1353)
     ...
Comment 3 Jan Stola 2011-09-06 14:35:33 UTC
The root of the IllegalAccessError is the following: Classes for Commons Logging are loaded by system class loader because of bug 50642. Unfortunately, there are two versions of Commons Logging inside NetBeans IDE by now. There is a version 1.1 in o.apache.commons.logging and version 1.1.1 in html.validation. System class loader refuses to load LogFactory arbitrarily from one of these locations. Hence, GUI Builder's ProjectClassLoader is used instead.

LogFactory$6 is new in version 1.1.1 of Commons Logging. Hence, the system class loader finds it in html.validation module only and loads it. Therefore, we end up with LogFactory$6 loaded by a different class loader than LogFactory and the result is the mentioned exception.

I have modified the corresponding code to attempt to load Commons Logging classes from o.apache.commons.logging module only.

Modified file: http://hg.netbeans.org/jet-main/rev/5bf995a5a3fb