Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1328

JMX setting for ConfigLocationUri does not pick the right classloader for "classpath:" locations

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5
    • Fix Version/s: None
    • Component/s: JMX
    • Labels:
      None

      Description

      The JMX ConfigLocationUri seems to partially struggle with “classpath:” Uris that point to the classpath of one of the webapps (I use log4j-web.jar in the webapp). I saw that the LoggerContextAdmin internally use “new URL(configLocation);” to load the file. So pressing "Enter" in JMX for releading the classpath log4j configuration, fails for some webapps because the configuration file will not be found.

      Here some output from the Jconsole Mbean:

      • Loading the Configlocation for the first webapp work, doing the same for the second one fail (but the file is present in the second webapp WEB-INF/classes folder)
        sorting table against column=0 ascending=true
        edit: ConfigLocationUri=classpath:/log4j2-webapp1.xml
        validating [row=2, column=1]: ConfigLocationUri=classpath:/log4j2-webapp1.xml
        setAttribute(ConfigLocationUri=classpath:/log4j2-webapp1.xml)
        sorting table against column=0 ascending=true
        edit: ConfigLocationUri=classpath:/log4j2-webapp2.xml
        validating [row=2, column=1]: ConfigLocationUri=classpath:/log4j2-webapp2.xml
        setAttribute(ConfigLocationUri=classpath:/log4j2-webapp2.xml)
        java.io.FileNotFoundException: Unable to load the resource [classpath:/log4j2-webapp2.xml] using the thread context class loader or the current classs class loader
        	at org.apache.naming.resources.ClasspathURLStreamHandler.openConnection(ClasspathURLStreamHandler.java:45)
        	at java.net.URL.openConnection(URL.java:972)
        	at java.net.URL.openStream(URL.java:1038)
        	at org.apache.logging.log4j.core.jmx.LoggerContextAdmin.setConfigLocationUri(LoggerContextAdmin.java:133)
        ...
        

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              thopap Thomas Papke
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: