pinpoint-apm/pinpoint · error · PinpointException

constructor not found

Error message

constructor not found 

What it means

TransformCallbackChecker.validate requires the TransformCallback class to expose a constructor matching the given parameterTypes, so the instrumentation layer can instantiate it reflectively. If getConstructor(parameterTypes) raises NoSuchMethodException, a PinpointException wrapping it is thrown.

Source

Thrown at agent-module/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/instrument/transformer/TransformCallbackChecker.java:57

        if (enclosingClass != null) {
            // inner class state

            // check static class
            int modifiers = transformCallbackClass.getModifiers();
            if (!Modifier.isStatic(modifiers)) {
                throw new PinpointException("transformCallbackClass must be static inner class. class:" + transformCallbackClass.getName());
            }
        }
//        final Method enclosingMethod = transformCallbackClass.getEnclosingMethod();
//        if (enclosingMethod != null) {
//            throw new PinpointException("Local Inner class not support " + transformCallbackClass.getName());
//        }

        try {
            // check default constructor
            transformCallbackClass.getConstructor(parameterTypes);
        } catch (NoSuchMethodException e) {
            throw new PinpointException("constructor not found " + transformCallbackClass.getName(), e);
        }
    }
}

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Add or fix a public constructor in the TransformCallback whose parameter types exactly match the parameterTypes array
  2. Pass null parameters/parameterTypes when the callback has a no-arg constructor path allowed by the API
  3. Make the constructor public — getConstructor only finds public constructors
  4. Align with supported parameter types (see ParameterUtils.checkParameterType)

Example fix

// before
transformer.transform("Foo", MyCallback.class, null, new Class[]{String.class}); // no String ctor
// after
class MyCallback implements TransformCallback {
    public MyCallback(String name) { ... }
}
transformer.transform("Foo", MyCallback.class, new Object[]{"x"}, new Class[]{String.class});
Defensive patterns

Strategy: validation

Validate before calling

try {
    MyCallback.class.getConstructor(parameterTypes == null ? new Class<?>[0] : parameterTypes);
} catch (NoSuchMethodException e) {
    throw new IllegalStateException("callback lacks public constructor matching parameterTypes");
}

Try / catch

try {
    transformer.transform(name, cb, params, types);
} catch (PinpointException e) {
    if (e.getMessage().startsWith("constructor not found")) {
        logger.error("add a public constructor matching parameterTypes: " + Arrays.toString(types), e);
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling TransformTemplate.transform(className, callbackClass, parameters, parameterTypes) where the callback class has no public constructor whose signature equals parameterTypes (e.g. callback declares no constructor but parameters are passed, or constructor parameter types differ).

Common situations: Passing parameters to a callback whose constructor takes none; mismatched types (int vs Integer, String vs custom type); constructor not public.

Related errors


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