NoClassDefFoundError sometimes for a standard class after System.out.close ()

My java program mysteriously crashes due to NoClassDefFoundError. The secret is that the exception message indicates that the problem class java/util/concurrent/CopyOnWriteArrayList$COWIteratoris part of the JRE. An exception occurs after other JRE classes are loaded without problems.

An exception is thrown from logback(version 1.1.3), it would seem when it iterates over the list of appenders lists for writing (I assume that it uses CopyOnWriteArrayListto store the list of additives):

Thread [main] (Suspended (exception NoClassDefFoundError))  
CopyOnWriteArrayList<E>.iterator() line: 959    
AppenderAttachableImpl<E>.appendLoopOnAppenders(E) line: 47 
Logger.appendLoopOnAppenders(ILoggingEvent) line: 273   
Logger.callAppenders(ILoggingEvent) line: 260   
Logger.buildLoggingEventAndAppend(String, Marker, Level, String, Object[], Throwable) line: 442 
Logger.filterAndLog_0_Or3Plus(String, Marker, Level, String, Object[], Throwable) line: 396 
Logger.info(String) line: 600   
MyProgramTextLogger.logStarting() line: 303 
MyProgram.run() line: 1686  
MyProgram.runProgram(MyProgram) line: 790   
MyProgram.main(String[]) line: 712  

Of course, the code logbackshould already load the class CopyOnWriteArrayListwhen it creates a list that it is trying to iterate over, so the class loader should have done its job correctly at this point.

, , , systemd. , daemon, systemd.

( static) , CopyOnWriteArrayList$COWIterator OK ( NoClassDefFoundError JRE). classloader .

java. java -showversion, , JVM JRE . :

 /usr/bin/java \
 -showversion \
 -jar /home/myuser/lib/my-app.jar --1 --latest

Java

 java version "1.7.0_75"
 OpenJDK Runtime Environment (rhel-2.5.4.2.el7_0-x86_64 u75-b13)
 OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

, : . , bkail , , , Java , .

, , . , , , "" , . , logback , , , Java.

. logback ( org.slf4j.LoggerFactory.getLogger(MyProgram.class)) Logger.info(String), , , , , :

 private static void closeSystemStreams() {
    try {
       System.in.close();
    } catch (IOException e) {
       // Do nothing; should never happen, and there is nothing we can do if
       // it does
    }
    System.out.close();
    System.err.close();
 }

, . , ( ), ?

, , logback JVM ?

+4
1

, Java , . , - . , , . .

+1

All Articles