Netflix/Hystrix · error · RuntimeException
Failed trying to wrap method [" + method.getName() + "] of c
Error message
Failed trying to wrap method [" + method.getName() + "] of class: " + className
What it means
Thrown by the hystrix-network-auditor javaagent when Javassist fails to inject the network-auditing hook into a matched method of a class being loaded. The agent iterates declared methods of transformed classes and calls method.insertBefore(...); any Exception (usually a Javassist CompileError from bad source insertion or an incompatible class) is rethrown as a RuntimeException naming the method and class.
Source
Thrown at hystrix-contrib/hystrix-network-auditor-agent/src/main/java/com/netflix/hystrix/contrib/networkauditor/NetworkClassTransform.java:109
try {
constructor.insertBefore("{ com.netflix.hystrix.contrib.networkauditor.HystrixNetworkAuditorAgent.notifyOfNetworkEvent(); }");
} catch (Exception e) {
throw new RuntimeException("Failed trying to wrap constructor of class: " + className, e);
}
}
}
// methods
CtMethod[] methods = ctClazz.getDeclaredMethods();
for (CtMethod method : methods) {
try {
for (String methodName : methodNames) {
if (method.getName().equals(methodName)) {
method.insertBefore("{ com.netflix.hystrix.contrib.networkauditor.HystrixNetworkAuditorAgent.handleNetworkEvent(); }");
}
}
} catch (Exception e) {
throw new RuntimeException("Failed trying to wrap method [" + method.getName() + "] of class: " + className, e);
}
}
return ctClazz.toBytecode();
}
}View on GitHub (pinned to 5ce3bc58c3)
Solutions
- Check the wrapped cause in the stack trace (getCause()) — it names the exact Javassist failure (e.g. CompileError) and method
- Upgrade/align the hystrix-network-auditor-agent version with the Hystrix and Javassist versions on the classpath
- Exclude the offending class/method from instrumentation via the agent's configured method/class filters
- If the agent is not essential, remove the -javaagent JVM flag to let the app start uninstrumented
Example fix
# before java -javaagent:hystrix-network-auditor-agent-1.5.x.jar -jar app.jar # after # pin matching versions and exclude the failing class java -javaagent:hystrix-network-auditor-agent-1.5.x.jar=excludedClasses=com.example.ProblemClass -jar app.jar
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
catch (RuntimeException e) where e.getMessage() starts with "Failed trying to wrap method" — log e.getCause() (the Javassist error) and the transform class name; decide between aborting startup (fail fast in test envs) or excluding the class and continuing.
Prevention
- Pin agent, Javassist, and Hystrix versions together
- Test the -javaagent against a full app startup in CI before deploying
- Keep an exclusion list config for classes that fail instrumentation
When it happens
Trigger: Running the JVM with -javaagent:hystrix-network-auditor-agent and loading a class whose method matches the agent's method-name filter but whose bytecode/signature cannot accept the inserted snippet (abstract/native methods, or a Javassist compile error on the inserted '{ ... }' block).
Common situations: Version skew between the agent (built against an old Javassist) and the target JVM/app classes; instrumenting native or abstract methods; a corrupted or obfuscated class hitting the ClassFileTransformer; agent jar missing a dependency at runtime.
Related errors
- Failed trying to wrap class: " + className
- Failed trying to wrap constructor of class: " + className
- HystrixNetworkAuditorEventListener can not be NULL
- HystrixCommandGroup can not be NULL
- " + getLogMessagePrefix() + " command executed multiple time
AI-assisted analysis of Netflix/Hystrix@5ce3bc58c3 (2026-08-14).
Data as JSON: /api/errors/be9890dc28a75915.
Report an issue: GitHub.