{"record":{"id":"10c9e23c4bfa1535","repo":"pinpoint-apm/pinpoint","slug":"modulefactory-initialize-fail","errorCode":null,"errorMessage":"{} ModuleFactory initialize fail","messagePattern":"(.+?) ModuleFactory initialize fail","errorType":"console","errorClass":"PinpointException","httpStatus":null,"severity":"critical","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultModuleFactoryResolver.java","lineNumber":75,"sourceCode":"        }\n        return DEFAULT_MODULE_FACTORY.equals(moduleFactoryClazzName);\n    }\n\n    @Override\n    public ModuleFactory resolve() {\n        logger.info(\"{} ModuleFactory lookup\", moduleFactoryClazzName);\n        if (isDefaultModuleFactory(moduleFactoryClazzName)) {\n            return new ApplicationContextModuleFactory();\n        }\n\n        ClassLoader classLoader = getClassLoader(DefaultModuleFactoryResolver.class.getClassLoader());\n        try {\n            final Class<? extends ModuleFactory> moduleFactoryClass =\n                    (Class<? extends ModuleFactory>) Class.forName(moduleFactoryClazzName, true, classLoader);\n            Constructor<? extends ModuleFactory> constructor = moduleFactoryClass.getConstructor();\n            return constructor.newInstance();\n        } catch (ReflectiveOperationException ex) {\n            logger.warn(\"{} ModuleFactory initialize fail\", moduleFactoryClazzName, ex);\n            throw new PinpointException(moduleFactoryClazzName + \" ModuleFactory initialize fail\", ex);\n        }\n    }\n\n    private ClassLoader getClassLoader(ClassLoader classLoader) {\n        return Objects.requireNonNull(classLoader, \"can't find classLoader\");\n    }\n\n}\n","sourceCodeStart":57,"sourceCodeEnd":85,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultModuleFactoryResolver.java#L57-L85","documentation":"DefaultModuleFactoryResolver.resolve() instantiates a ModuleFactory class by its fully-qualified name via reflection (Class.forName + getConstructor + newInstance). This error is thrown, wrapped in PinpointException, when any reflective step fails: the class cannot be found, has no no-arg constructor, is not a ModuleFactory subtype, or its constructor throws.","triggerScenarios":"Starting the Pinpoint agent with profiler.module.factory (or equivalent config) pointing to a class name that is misspelled, missing from the classpath, lacking a public no-arg constructor, or whose constructor throws during initialization.","commonSituations":"Typo in the module factory class name in pinpoint.config, custom ModuleFactory jar not on the agent bootclasspath, renaming/moving of factory classes after a Pinpoint version upgrade, shading issues that drop the class from the built artifact.","solutions":["Verify the configured class name is correct and matches the exact FQCN of a ModuleFactory implementation","Ensure the jar containing the factory is on the agent classpath (boot-dir/lib of the Pinpoint agent)","Confirm the class has a public no-arg constructor","Check the nested ReflectiveOperationException cause in the log — ClassNotFoundException vs NoSuchMethodException vs constructor-thrown exception points to the specific fix","After a Pinpoint upgrade, verify the factory class was not relocated; use the built-in DefaultModuleFactory if a custom one is no longer compatible"],"exampleFix":"// before (pinpoint.config)\nprofiler.module.factory=com.example.MyModuleFactory\n// after (class exists and has public no-arg constructor)\npackage com.example;\npublic class MyModuleFactory implements ModuleFactory {\n  public MyModuleFactory() { }\n  ...\n}","handlingStrategy":"try-catch","validationCode":"try { Class.forName(factoryClassName, true, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { throw new IllegalStateException(\"ModuleFactory not on classpath: \" + factoryClassName, e); }","typeGuard":"boolean isValidModuleFactory(String fqcn) { try { Class<?> c = Class.forName(fqcn); return ModuleFactory.class.isAssignableFrom(c) && java.lang.reflect.Modifier.isPublic(c.getModifiers()); } catch (Throwable t) { return false; } }","tryCatchPattern":"try {\n  moduleFactoryResolver.resolve(factoryClassName);\n} catch (PinpointException e) {\n  logger.error(\"Failed to resolve ModuleFactory {}; check class name and agent classpath\", factoryClassName, e.getCause());\n  throw e;\n}","preventionTips":["Store the factory FQCN in one constants class and reference it from config","Smoke-test agent startup in CI with the exact agent distribution used in production","After Pinpoint upgrades, grep the new version for relocated factory classes","Ensure custom modules are packaged into the agent's lib/boot directory"],"tags":["reflection","classpath","configuration","module-factory"],"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"}