pinpoint-apm/pinpoint · warning

Error creating ShutdownHookRegister [{}]

Error message

Error creating ShutdownHookRegister [{}]

What it means

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.

Source

Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/ShutdownHookRegisterProvider.java:109

    private ShutdownHookRegister createShutdownHookRegister(String classToLoad) {
        if (classToLoad == null) {
            return RUNTIME_SHUTDOWN_HOOK_REGISTER;
        }

        try {
            @SuppressWarnings("unchecked")
            Class<ShutdownHookRegister> shutdownHookRegisterClass = (Class<ShutdownHookRegister>) Class.forName(classToLoad);

            try {
                Constructor<ShutdownHookRegister> shutdownHookRegisterConstructorConstructor = shutdownHookRegisterClass.getConstructor();
                return shutdownHookRegisterConstructorConstructor.newInstance();
            } catch (NoSuchMethodException e) {
                logger.warn("Unknown ShutdownHookRegister : {}", classToLoad);
                return RUNTIME_SHUTDOWN_HOOK_REGISTER;
            }
        } catch (ReflectiveOperationException e) {
            logger.warn("Error creating ShutdownHookRegister [" + classToLoad + "]", e);
        }
        return RUNTIME_SHUTDOWN_HOOK_REGISTER;
    }

    private static class RuntimeShutdownHookRegister implements ShutdownHookRegister {

        private final Logger logger = LogManager.getLogger(this.getClass());

        @Override
        public void register(Thread thread) {
            Runtime.getRuntime().addShutdownHook(thread);
            logger.info("register() completed. (ShutdownHook registered in java.lang.Runtime.)");
        }

    }

}

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Check the configured class name in pinpoint.config and fix the fully-qualified class name typo
  2. Ensure the class (and a public no-arg constructor) actually exists in the agent jar/classpath
  3. Inspect the chained ReflectiveOperationException (ClassNotFoundException vs NoSuchMethodException vs InvocationTargetException) in the stack trace to identify load vs construct failure
  4. 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

Example fix

// before (pinpoint.config)
profiler.shutdown.hook.register=com.example.MyShutdownHookRegister
// after
profiler.shutdown.hook.register=com.navercorp.pinpoint.profiler.context.active.ActiveTraceShutDownHookRegister
Defensive patterns

Strategy: fallback

Validate before calling

try { Class<?> c = Class.forName(cfg.get("profiler.shutdown.hook.register")); c.getConstructor(); } catch (ClassNotFoundException | NoSuchMethodException e) { /* fix config before agent start */ }

Try / catch

try { return ctor.newInstance(); } catch (ReflectiveOperationException e) { logger.warn("Error creating ShutdownHookRegister", e); return RUNTIME_SHUTDOWN_HOOK_REGISTER; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/dd437287dea4cc23. Report an issue: GitHub.