You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "cmolodowitch (via GitHub)" <gi...@apache.org> on 2023/04/07 19:22:02 UTC

[GitHub] [netbeans] cmolodowitch opened a new issue, #5791: Parent GUI Builder can't load child component using Log4j2 logger without class name

cmolodowitch opened a new issue, #5791:
URL: https://github.com/apache/netbeans/issues/5791

   ### Apache NetBeans version
   
   Apache NetBeans 17
   
   ### What happened
   
   ### Issue
   If you create a custom Java Swing GUI component that declares an Apache log4j2 Logger without specifying the class, and then try to use that component in another custom Java Swing GUI component using the GUI builder, the parent GUI builder fails to load the child component with a nested UnsupportedOperationException from log4j2.  See attached sample stacktrace.
   
   ### Expected Behavior
   The GUI builder for the parent should be able to load the child component without throwing the UnsupportedOperationException.
   
   ### Notes
   Interestingly, the GUI builder for the child component itself is fine - it will load without any problems.  It's just when the parent container tries to load that the GUI builder throws an error.
   
   This is presumably related to log4j2 being a multi-release jar, and changes in JDK 9+.  If you use an older version of Netbeans that can run on JDK 8 (I tried it with Netbeans 12.6), the GUI builder has no issues.
   
   ### Workaround
   Specify the class name when creating an Apache log4j2 Logger.
   
   [sample_stacktrace.txt](https://github.com/apache/netbeans/files/11180971/sample_stacktrace.txt)
   
   ### How to reproduce
   
   In Netbeans 17 running on JDK 11+, create a custom Swing component - this can be done either using one of the GUI Builder forms or just manually creating the class.  Declare an Apache log4j2 Logger property without specifying the class name:
   
   Create another Swing GUI JPanel form class.  Try to drag the child component into the new JPanel form in the GUI Builder - this will trigger an ExceptionInitializerError with a nested UnsupportedOperationException.
   
   Alternatively, use LOG declarations that specify the class names and drag the ChildPanel/ChildTable into the ParentPanel GUI Builder.  Close the ParentPanel class and modify the ChildPanel/ChildTable to use the LOG declarations that don't specify the class name.  Then re-open the ParentPanel class to reload the GUI Builder and trigger exceptions when initializing the child components.
   
   Sample stacktrace attached.
   
   ```java
   // ChildPanel created using Netbeans "new JPanel Form..." creation
   // Note that the GUI Builder for this class displays with no issues, no matter how the LOG is created.
   public class ChildPanel extends javax.swing.JPanel {
       // Using this declaration causes an error in the parent GUI Builder
       private static final Logger LOG = LogManager.getLogger();
       // Specifying the class removes the error
       // private static final Logger LOG = LogManager.getLogger(ChildPanel.class);
   }
   
   // ChildTable written manually, without a GUI Builder
   public class ChildTable extends JTable {
       // Using this declaration causes an error in the parent GUI Builder
       private static final Logger LOG = LogManager.getLogger();
       // Specifying the class removes the error
       // private static final Logger LOG = LogManager.getLogger(ChildTable.class);
   }
   
   // ParentPanel created using Netbeans "new JPanel Form..." creation
   // In GUI Builder, try to drag either ChildPanel or ChildTable into the panel to trigger an exception.
   public class ParentPanel extends javax.swing.JPanel {
   }
   ```
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Windows 10 Pro
   
   ### JDK
   
   JDK 17
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer
   
   ### Anything else
   
   This error occurs no matter what JDK the Java project uses - it's dependent on the JDK version used by Netbeans, not on the project JDK.
   
   ### Are you willing to submit a pull request?
   
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists