JVM option --XX MaxJavaStackTraceDepth when I decrease any value below 10, It is not working

616 Views Asked by At

I am trying to set the jvm option maxJavaStackTraceDepth. So when I increase the JVM option --XX MaxJavaStackTraceDepth above 10. it is working as expected. But when I decrease any value below 10 so it causes NoClassDefFoundError error.

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.message.ReusableMessageFactory
        at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2108)
        at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2015)
        at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1886)
        at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:849)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:130)

Ideally it should work below 10 values as well like -XX:MaxJavaStackTraceDepth=5 I am using Java 17

1

There are 1 best solutions below

0
Arun Pal On

I did research on it. I have below observation.

When we decrease jvm option MaxJavaStackTraceDepth below a certain threshold, such as 10, it may not work as expected because it can affect the ability of the JVM to provide meaningful stack traces when exceptions are thrown.

Stack traces are crucial for diagnosing and debugging issues in Java applications, as they provide information about the sequence of method calls leading to an exception or error. When the MaxJavaStackTraceDepth is set too low, the JVM may not capture enough information in the stack trace to understand the context of the problem.

It's generally not recommended to set MaxJavaStackTraceDepth to a very low value, especially below 10.