{"record":{"id":"dd437287dea4cc23","repo":"pinpoint-apm/pinpoint","slug":"error-creating-shutdownhookregister","errorCode":null,"errorMessage":"Error creating ShutdownHookRegister [{}]","messagePattern":"Error creating ShutdownHookRegister \\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/ShutdownHookRegisterProvider.java","lineNumber":109,"sourceCode":"\n    private ShutdownHookRegister createShutdownHookRegister(String classToLoad) {\n        if (classToLoad == null) {\n            return RUNTIME_SHUTDOWN_HOOK_REGISTER;\n        }\n\n        try {\n            @SuppressWarnings(\"unchecked\")\n            Class<ShutdownHookRegister> shutdownHookRegisterClass = (Class<ShutdownHookRegister>) Class.forName(classToLoad);\n\n            try {\n                Constructor<ShutdownHookRegister> shutdownHookRegisterConstructorConstructor = shutdownHookRegisterClass.getConstructor();\n                return shutdownHookRegisterConstructorConstructor.newInstance();\n            } catch (NoSuchMethodException e) {\n                logger.warn(\"Unknown ShutdownHookRegister : {}\", classToLoad);\n                return RUNTIME_SHUTDOWN_HOOK_REGISTER;\n            }\n        } catch (ReflectiveOperationException e) {\n            logger.warn(\"Error creating ShutdownHookRegister [\" + classToLoad + \"]\", e);\n        }\n        return RUNTIME_SHUTDOWN_HOOK_REGISTER;\n    }\n\n    private static class RuntimeShutdownHookRegister implements ShutdownHookRegister {\n\n        private final Logger logger = LogManager.getLogger(this.getClass());\n\n        @Override\n        public void register(Thread thread) {\n            Runtime.getRuntime().addShutdownHook(thread);\n            logger.info(\"register() completed. (ShutdownHook registered in java.lang.Runtime.)\");\n        }\n\n    }\n\n}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/ShutdownHookRegisterProvider.java#L91-L127","documentation":"Warn logged by ShutdownHookRegisterProvider when reflective instantiation of the configured ShutdownHookRegister class fails with a ReflectiveOperationException. The provider is asked to build a shutdown-hook register via Class.forName plus a no-arg constructor; if the class cannot be loaded or constructed, the provider degrades to RuntimeShutdownHookRegister, which registers hooks only for JVM runtime shutdown. The agent still starts, but the intended shutdown-hook behavior is silently downgraded.","triggerScenarios":"The profiler.test or shutdown-hook related config points to a class name that does not exist on the agent classpath, is not on the bootstrapped loader, lacks a public no-arg constructor, or whose constructor throws.","commonSituations":"Typo in the fully-qualified class name in pinpoint.config; renaming/moving the custom ShutdownHookRegister class without updating config; running an agent build where the default implementation was refactored; constructor throwing due to JVM-version-specific APIs.","solutions":["Check the configured class name in pinpoint.config and fix the fully-qualified class name typo","Ensure the class (and a public no-arg constructor) actually exists in the agent jar/classpath","Inspect the chained ReflectiveOperationException (ClassNotFoundException vs NoSuchMethodException vs InvocationTargetException) in the stack trace to identify load vs construct failure","If a custom constructor throwing is the cause, fix or guard the constructor logic; accept the RuntimeShutdownHookRegister fallback only if runtime-only shutdown handling is acceptable"],"exampleFix":"// before (pinpoint.config)\nprofiler.shutdown.hook.register=com.example.MyShutdownHookRegister\n// after\nprofiler.shutdown.hook.register=com.navercorp.pinpoint.profiler.context.active.ActiveTraceShutDownHookRegister","handlingStrategy":"fallback","validationCode":"try { Class<?> c = Class.forName(cfg.get(\"profiler.shutdown.hook.register\")); c.getConstructor(); } catch (ClassNotFoundException | NoSuchMethodException e) { /* fix config before agent start */ }","typeGuard":null,"tryCatchPattern":"try { return ctor.newInstance(); } catch (ReflectiveOperationException e) { logger.warn(\"Error creating ShutdownHookRegister\", e); return RUNTIME_SHUTDOWN_HOOK_REGISTER; }","preventionTips":["Validate fully-qualified class names in pinpoint.config at startup with a dry-run Class.forName","Keep custom shutdown-hook classes in the agent's own jar or plugin lib directory","Add a startup self-test that asserts the configured register instantiates","Watch logs after agent upgrades for this fallback warning"],"tags":["reflection","class-loading","fallback","config"],"backgroundTag":"class-not-found","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}