[ https://issues.apache.org/jira/browse/LOG4J2-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17500248#comment-17500248 ]
Ernie Rael commented on LOG4J2-3420: ------------------------------------ Initial response on the NB mailing list is {noformat} NetBeans has some support for multi-release jars. {noformat} There's some discussion on which class loader is used by the gui builder. > getlogger() UnsupportedOperationException when loaded by Class.forName() > ------------------------------------------------------------------------ > > Key: LOG4J2-3420 > URL: https://issues.apache.org/jira/browse/LOG4J2-3420 > Project: Log4j 2 > Issue Type: Bug > Components: API > Affects Versions: 2.17.2 > Environment: Several versions of log4j 2. > Tried with several versions of jdk (the exception shown is jdk-17). > > Reporter: Ernie Rael > Assignee: Ralph Goers > Priority: Major > > Exception arises when this class is used in the NetBeans guiBuilder. > {code:java} > public class MyTextField extends JTextField { > final private static Logger logger = LogManager.getLogger(); > public MyTextField(){} > } > {code} > Get the following exception when the bean is selected to drop on the gui. > {noformat} > INFO [org.netbeans.modules.form.MetaComponentCreator]: Cannot load component > class play.MyTextField from unknown source. > The class itself was found, but there was a problem initializing it, e.g. due > to an exception in static initializer, or failure in loading an additional > class needed by the component class. Check the attached exception. > java.lang.UnsupportedOperationException: No class provided, and an > appropriate one cannot be found. > at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:573) > at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:598) > at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:585) > at play.MyTextField.<clinit>(MyTextField.java:35) > Caused: java.lang.ExceptionInInitializerError > at java.base/java.lang.Class.forName0(Native Method) > at java.base/java.lang.Class.forName(Class.java:467) > at > org.netbeans.modules.form.project.ClassPathUtils.loadClass(ClassPathUtils.java:89) > {noformat} > This exception similarly occurs with clazz.newInstance(), which is sometimes > used by the guiBuilder. It also occurs if the getLogger is in the constructor > rather than a static. > As a workaround, since I can compile the gui component, I'm invoking > Stuff.getLogger() > {code:java} > public class Stuff { > static Logger getLogger() { > try { > return LogManager.getLogger(StackLocatorUtil.getCallerClass(2)); > } catch(UnsupportedOperationException ex) {} > return LogManager.getRootLogger(); > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.1#820001)