alibaba/druid · error · SQLException

load managed jdbc driver event listener error. {filterName}

Error message

load managed jdbc driver event listener error. {filterName}

What it means

Thrown by FilterManager.loadFilter while instantiating a filter class that was resolved through the META-INF alias mapping (the getFilter(...) branch that returns a comma-separated class list). The InstantiationException means the class loaded successfully but Class.newInstance() cannot create an instance because the class is abstract, an interface, an array class, or has no accessible no-arg constructor. Note the message echoes the original filterName alias rather than the concrete filterClassName, which can obscure which class actually failed.

Source

Thrown at core/src/main/java/com/alibaba/druid/filter/FilterManager.java:130

                Class<?> filterClass = Utils.loadClass(filterClassName);

                if (filterClass == null) {
                    LOG.error("load filter error, filter not found : " + filterClassName);
                    continue;
                }

                Filter filter;

                try {
                    filter = (Filter) filterClass.newInstance();
                } catch (ClassCastException e) {
                    LOG.error("load filter error.", e);
                    continue;
                } catch (NoSuchFieldError e) {
                    LOG.error("load filter error.", e);
                    continue;
                } catch (InstantiationException e) {
                    throw new SQLException("load managed jdbc driver event listener error. " + filterName, e);
                } catch (IllegalAccessException e) {
                    throw new SQLException("load managed jdbc driver event listener error. " + filterName, e);
                } catch (RuntimeException e) {
                    throw new SQLException("load managed jdbc driver event listener error. " + filterName, e);
                }

                filters.add(filter);
            }

            return;
        }

        if (existsFilter(filters, filterName)) {
            return;
        }

        Class<?> filterClass = Utils.loadClass(filterName);
        if (filterClass == null) {

View on GitHub (pinned to fa8dc99126)

Solutions

  1. Open META-INF/druid/filter.properties for the alias and confirm the mapped class is a concrete public class with a public no-arg constructor.
  2. If registering a custom filter, make it a concrete class extending FilterAdapter (or implementing Filter) and remove any abstract modifier.
  3. Check for druid JAR version conflicts (mvn dependency:tree) where an older filter class is abstract in one version.
  4. Temporarily raise logging on com.alibaba.druid.filter.FilterManager and Utils.loadClass to see the concrete filterClassName being resolved before the failure.

Example fix

// before (filter.properties maps alias to abstract class)
// myfilter=com.example.AbstractBaseFilter

// after
// myfilter=com.example.ConcreteImplFilter  (public class, public no-arg ctor)
Defensive patterns

Strategy: validation

Validate before calling

Class<?> c = Utils.loadClass(filterClassName);
if (c == null) { /* alias unresolved - handle before setFilters */ }
int mod = c.getModifiers();
if (Modifier.isAbstract(mod) || Modifier.isInterface(mod)) {
    throw new IllegalStateException(filterClassName + " is abstract/interface - cannot instantiate");
}
try { c.getConstructor(); } catch (NoSuchMethodException e) {
    throw new IllegalStateException(filterClassName + " has no public no-arg constructor");
}

Try / catch

try {
    ds.setFilters(filterName);
    ds.init();
} catch (SQLException e) {
    if (e.getMessage().contains("load managed jdbc driver event listener error")) {
        Throwable cause = e.getCause(); // InstantiationException / IllegalAccessException / RuntimeException
        // resolve alias -> concrete class in META-INF/druid/filter.properties, fix the class
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling DruidDataSource.setFilters("<alias>") or passing filters in JDBC URL where the alias resolves (via META-INF/druid/filter.properties) to a class that is abstract or lacks a public no-arg constructor. The exact line is the catch (InstantiationException) inside the for-loop over filterClassNames.split(",").

Common situations: A custom filter registered in filter.properties points at an abstract base class; a JAR version mismatch where a Druid filter class was refactored to abstract; someone manually edited filter.properties to name an interface FQN.

Related errors


AI-assisted analysis of alibaba/druid@fa8dc99126 (2026-08-14). Data as JSON: /api/errors/e8dc40b311a1205d. Report an issue: GitHub.