flowable/flowable-engine · error · FlowableException

couldn't instantiate " + implementationClass.getName() + "…

Error message

couldn't instantiate " + implementationClass.getName() + ": " + e.getMessage()

What it means

This deprecated GenericManagerFactory constructor instantiates the session implementation class reflectively via its no-arg constructor. If instantiation fails (no public no-arg constructor, abstract class, constructor throws), it wraps the failure in a FlowableException naming the class and the underlying message.

Solutions

  1. Use the non-deprecated GenericManagerFactory(Class, Supplier) constructor, e.g. new GenericManagerFactory<>(MySession.class, MySession::new)
  2. Ensure the implementation class has a public no-arg constructor and is concrete
  3. If dependencies are needed, use the supplier variant to construct it with arguments

Example fix

// before
new GenericManagerFactory<>(MySession.class, MySessionImpl.class);
// after
new GenericManagerFactory<>(MySession.class, () -> new MySessionImpl(depA, depB));
Defensive patterns

Strategy: try-catch

Validate before calling

// check the implementation class is instantiable
Class<?> c = implementationClass;
if (c.isInterface() || java.lang.reflect.Modifier.isAbstract(c.getModifiers()))
    throw new IllegalArgumentException("must be concrete");
c.getDeclaredConstructor(); // throws NoSuchMethodException if no no-arg ctor

Try / catch

try {
    new GenericManagerFactory<>(MySession.class, MySessionImpl.class);
} catch (FlowableException e) {
    if (e.getMessage().startsWith("couldn't instantiate")) {
        // fall back to supplier-based factory
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling the deprecated constructor GenericManagerFactory(typeClass, implementationClass) where implementationClass lacks an accessible no-arg constructor, is abstract/an interface, or whose constructor throws an exception.

Common situations: Custom session/manager implementations that require constructor dependencies; wiring an interface or abstract class by mistake; upgrading Flowable where a manager class gained required constructor arguments.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/ecfd77c075297e71. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/GenericManagerFactory.java:51

    public GenericManagerFactory(Class<? extends Session> typeClass, Supplier<? extends Session> sessionCreator) {
        this(typeClass, context -> sessionCreator.get());
    }

    public GenericManagerFactory(Class<? extends Session> typeClass, Function<CommandContext, ? extends Session> sessionCreator) {
        this.typeClass = typeClass;
        this.sessionCreator = sessionCreator;
    }

    /**
     * @deprecated use {@link #GenericManagerFactory(Class, Supplier)} instead
     */
    @Deprecated
    public GenericManagerFactory(Class<? extends Session> typeClass, Class<? extends Session> implementationClass) {
        this(typeClass, commandContext -> {
            try {
                return implementationClass.getConstructor().newInstance();
            } catch (Exception e) {
                throw new FlowableException("couldn't instantiate " + implementationClass.getName() + ": " + e.getMessage(), e);
            }
        });
    }

    /**
     * @deprecated use {@link #GenericManagerFactory(Class, Supplier)} instead
     */
    @Deprecated
    public GenericManagerFactory(Class<? extends Session> implementationClass) {
        this(implementationClass, implementationClass);
    }

    @Override
    public Class<?> getSessionType() {
        return typeClass;
    }

    @Override

View on GitHub (pinned to d6d39ce1c6)