Skip to content

Instantly share code, notes, and snippets.

@amoe
Last active December 20, 2015 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amoe/6069573 to your computer and use it in GitHub Desktop.
Save amoe/6069573 to your computer and use it in GitHub Desktop.
Log4j2 and openjdk-7-jdk 7u25-2.3.10-1~deb7u1 produces OutOfMemoryError
package ic.log4j2test;
import java.io.IOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Log4j2Test {
private static Logger log = LogManager.getLogger("Hello");
public static void main(String[] args) {
try {
log.error("INSIDE TRY BLOCK");
throw new IOException("KILLAH");
} catch (IOException e) {
log.error("WHUT", e);
}
}
}
amoe@kruis $ uname -a
Linux kruis 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 GNU/Linux
amoe@kruis $ java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1~deb7u1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
amoe@kruis $ mvn -q clean compile assembly:single
amoe@kruis $ java -jar target/log4j2-test-1-jar-with-dependencies.jar
11:41:57.732 [main] ERROR Hello - INSIDE TRY BLOCK
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2245)
at java.util.Arrays.copyOf(Arrays.java:2219)
at java.util.Vector.grow(Vector.java:262)
at java.util.Vector.ensureCapacityHelper(Vector.java:242)
at java.util.Vector.addElement(Vector.java:616)
at java.util.Stack.push(Stack.java:67)
at org.apache.logging.log4j.core.impl.ThrowableProxy.getCurrentStack(ThrowableProxy.java:297)
at org.apache.logging.log4j.core.impl.ThrowableProxy.<init>(ThrowableProxy.java:69)
at org.apache.logging.log4j.core.impl.Log4jLogEvent.<init>(Log4jLogEvent.java:112)
at org.apache.logging.log4j.core.impl.Log4jLogEvent.<init>(Log4jLogEvent.java:83)
at org.apache.logging.log4j.core.impl.DefaultLogEventFactory.createEvent(DefaultLogEventFactory.java:49)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:366)
at org.apache.logging.log4j.core.Logger.log(Logger.java:110)
at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:609)
at ic.log4j2test.Log4j2Test.main(Log4j2Test.java:16)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ic.log4j2test</groupId>
<artifactId>log4j2-test</artifactId>
<version>1</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta8</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>ic.log4j2test.Log4j2Test</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>ic.log4j2test.Log4j2Test</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>ic.log4j2test.Log4j2Test</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment