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

Log4j getCaller class is not found in Java 11

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.13.2
    • None
    • API
    • None
    • Java

      Java JDK 11.0.7

      IDE

      Eclipse 2020-03 (4.15.0)

      Windows

      Windows 1903 18362.778

    Description

      I can't seem to fix Log4j crashing when calling the `LogManager.getLogger()` method. I found [this|https://stackoverflow.com/questions/52953483/logmanager-getlogger-is-unable-to-determine-class-name-on-java-11] thread and I included the `Multi-Release` property in the manifest file but Log4J still crashes.

      What I did was include Log4J in a library I wrote and then packaged that library using the maven shade plugin and then I included my packaged library in my actual application.

      The error I'm getting:

      Exception in thread "main" java.lang.UnsupportedOperationException: No class provided, and an appropriate one cannot be found.
      at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:576)    
      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:601)    
      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:588)

       

      The shade configuration in my pom file for the library:

      <plugin>    
          <groupId>org.apache.maven.plugins</groupId>    
          <artifactId>maven-shade-plugin</artifactId>    
          <version>3.2.3</version>
          <executions>    
              <execution>    
                  <phase>package</phase>    
                  <goals>    
                      <goal>shade</goal>    
                  </goals>    
                  <configuration>    
                      <filters>    
                          <filter>    
                              <artifact>:</artifact>    
                              <excludes>    
                                  <exclude>META-INF/.SF</exclude>    
                                  <exclude>META-INF/.DSA</exclude>    
                                  <exclude>META-INF/*.RSA</exclude>    
                              </excludes>    
                          </filter>    
                      </filters>    
                      <transformers>    
                          <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                              <manifestEntries>    
                                  <Multi-Release>true</Multi-Release>    
                              </manifestEntries>    
                          </transformer>    
                          <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                          </transformers>    
                      <finalName>uber-${project.artifactId}-${project.version}</finalName>
                  </configuration>    
              </execution>    
          </executions>    
      </plugin>

       

      The manifest file in the library .jar file:

      Manifest-Version: 1.0
      Archiver-Version: Plexus Archiver
      Created-By: Apache Maven 3.6.3
      Build-Jdk: 11.0.7
      Multi-Release: true

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Mininotallarines Jarno Gabriel
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: