apache/dubbo · error · RuntimeException
${cause.message}
Error message
${cause.message} What it means
Thrown by ClassGenerator.toClass() when javassist cannot turn the generated bytecode into a Class. NotFoundException means a referenced class/method/field could not be found during compilation; CannotCompileException means the generated method bodies violated JVM or javassist constraints. Both are rewrapped as RuntimeException(cause.message, cause).
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/ClassGenerator.java:370
String[] sn = mCtc.getSimpleName().split("\\$+"); // inner class name include $.
mCtc.addConstructor(
CtNewConstructor.make(code.replaceFirst(SIMPLE_NAME_TAG, sn[sn.length - 1]), mCtc));
}
}
}
try {
return mPool.toClass(mCtc, neighborClass, loader, pd);
} catch (Throwable t) {
if (!(t instanceof CannotCompileException)) {
return mPool.toClass(mCtc, loader, pd);
}
throw t;
}
} catch (RuntimeException e) {
throw e;
} catch (NotFoundException | CannotCompileException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public void release() {
if (mCtc != null) {
mCtc.detach();
}
if (mInterfaces != null) {
mInterfaces.clear();
}
if (mFields != null) {
mFields.clear();
}
if (mMethods != null) {
mMethods.clear();
}
if (mConstructors != null) {
mConstructors.clear();View on GitHub (pinned to 3a3043227f)
Solutions
- Inspect getCause(): NotFoundException => add the missing class jar to the classpath; CannotCompileException => fix the generated method descriptor.
- Ensure every interface and its parameter/return types are loadable by the classloader passed to getProxy/mixin.
- Reduce the interface surface or split proxies so each references resolvable types.
- Reproduce with Proxy.getProxy(YourInterface.class) in a unit test to isolate the failing interface.
Example fix
// before Proxy p = Proxy.getProxy(MissingDepsInterface.class); // references absent types // after // add the jar providing MissingDepsInterface's parameter types, then: Proxy p = Proxy.getProxy(MissingDepsInterface.class);
Defensive patterns
Strategy: try-catch
Validate before calling
for (Class<?> ic : ics) {
for (Method m : ic.getMethods()) {
for (Class<?> pt : m.getParameterTypes()) {
Class.forName(pt.getName(), false, loader); // throws if a referenced type is missing
}
}
} Try / catch
try {
Proxy.getProxy(ics);
} catch (RuntimeException e) {
Throwable c = e.getCause();
if (c instanceof javassist.NotFoundException) { /* missing class */ }
else if (c instanceof javassist.CannotCompileException) { /* bad bytecode */ }
} Prevention
- Ensure every interface and its parameter/return types are loadable by the ClassLoader passed to the proxy.
- Reproduce Proxy.getProxy(Iface.class) in a unit test to isolate the failing interface.
- Keep javassist on the classpath at the version bundled with your Dubbo release.
When it happens
Trigger: Calling ccp.toClass(...) on a ClassGenerator whose added methods/fields reference classes missing from the pool, or whose generated source text is malformed (bad descriptors, duplicate methods, illegal bytecode).
Common situations: Dubbo Proxy/Mixin generation against interfaces whose referenced types are not visible to the generating ClassLoader; a method signature using a class not on the classpath; conflicting method overloads producing duplicate bytecode; very large generated classes hitting JVM limits.
Related errors
- Method [{}] unimplemented.
- interface limit exceeded
- {} is not a interface.
- {} is not visible from class loader
- non-public interfaces from different packages
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/fbd646fb44f74e46.
Report an issue: GitHub.