{"record":{"id":"c08fd9d2561ee2e6","repo":"stanfordnlp/CoreNLP","slug":"could-not-find-java-util-logging-in-your-classpath","errorCode":null,"errorMessage":"Could not find java.util.logging in your classpath","messagePattern":"Could not find java\\.util\\.logging in your classpath","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/logging/RedwoodConfiguration.java","lineNumber":249,"sourceCode":"      try {\n        OutputHandler handler = MetaClass.create(\"edu.stanford.nlp.util.logging.SLF4JHandler\").createInstance();\n        handler.leftMargin = config.channelWidth;\n        root.addChild(handler);\n      } catch (Exception e) {\n        throw new IllegalStateException(\"Could not find SLF4J in your classpath\", e);\n      }\n    };\n\n    /**\n     * Output to java.util.Logging. This is a leaf node.\n     */\n    public static final Thunk javaUtil = (config, root) -> {\n      try {\n        OutputHandler handler = new JavaUtilLoggingHandler();\n        handler.leftMargin = config.channelWidth;\n        root.addChild(handler);\n      } catch (Exception e) {\n        throw new IllegalStateException(\"Could not find java.util.logging in your classpath\", e);\n      }\n    };\n\n    /**\n     * Output to the default location specified by the output() method.\n     * Consider using this rather than stderr or stdout.\n     */\n    public static final Thunk output = (config, root) -> {\n      config.outputHandler.leftMargin = config.channelWidth;\n      root.addChild(config.outputHandler);\n    };\n\n    //\n    // Filters\n    //\n    /**\n     * Hide the debug channel only.\n     */","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/logging/RedwoodConfiguration.java#L231-L267","documentation":"Handlers.javaUtil Thunk wraps construction of a JavaUtilLoggingHandler; any Exception during creation is rethrown as this IllegalStateException. Despite the message, java.util.logging is part of the JDK, so failures are almost always reflective/linkage errors in exotic environments.","triggerScenarios":"Using Handlers.javaUtil (log.handlers containing javaUtil) in a constrained JVM where java.util.logging classes fail to load, or where the handler construction throws (e.g. NoClassDefFoundError-style Exception in stripped JREs).","commonSituations":"Running on a stripped/minimal JRE image without java.util.logging module; unusual classloader setups (old app servers) that block java.util.logging; extremely rare genuine ClassNotFound situations.","solutions":["Check the cause chain to see the actual class that failed to load; in modern JDKs java.util.logging is always present, so suspect the classloader.","Switch to Handlers.stderr or Handlers.output which need no java.util.logging.","If running a custom runtime image, include the java.logging module (jlink --add-modules java.logging).","Initialize java.util.logging (LogManager) once early to surface the real underlying error."],"exampleFix":"// before\nRedwoodConfiguration.empty().handlers(Handlers.javaUtil).apply();\n// after\nRedwoodConfiguration.empty().handlers(Handlers.stderr).apply(); // or add java.logging module to runtime image","handlingStrategy":"fallback","validationCode":"private static boolean javaUtilLoggingAvailable() {\n  try { Class.forName(\"java.util.logging.Logger\"); return true; }\n  catch (ClassNotFoundException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.handlers(Handlers.javaUtil).apply();\n} catch (IllegalStateException e) {\n  if (e.getMessage().contains(\"Could not find java.util.logging\")) {\n    config.handlers(Handlers.stderr).apply();\n  } else throw e;\n}","preventionTips":["Ensure the runtime image includes the java.logging module (jlink --add-modules java.logging).","Read the cause chain to distinguish a stripped JRE from a classloader problem.","Prefer Handlers.output/stderr in constrained deployment environments."],"tags":["logging","java-util-logging","classpath","module-missing"],"backgroundTag":"missing-dependency","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}