{"record":{"id":"be9890dc28a75915","repo":"Netflix/Hystrix","slug":"failed-trying-to-wrap-method-method-getname","errorCode":null,"errorMessage":"Failed trying to wrap method [\" + method.getName() + \"] of class: \" + className","messagePattern":"Failed trying to wrap method \\[\" \\+ method\\.getName\\(\\) \\+ \"\\] of class: \" \\+ className","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hystrix-contrib/hystrix-network-auditor-agent/src/main/java/com/netflix/hystrix/contrib/networkauditor/NetworkClassTransform.java","lineNumber":109,"sourceCode":"                try {\n                    constructor.insertBefore(\"{ com.netflix.hystrix.contrib.networkauditor.HystrixNetworkAuditorAgent.notifyOfNetworkEvent(); }\");\n                } catch (Exception e) {\n                    throw new RuntimeException(\"Failed trying to wrap constructor of class: \" + className, e);\n                }\n\n            }\n        }\n        // methods\n        CtMethod[] methods = ctClazz.getDeclaredMethods();\n        for (CtMethod method : methods) {\n            try {\n                for (String methodName : methodNames) {\n                    if (method.getName().equals(methodName)) {\n                        method.insertBefore(\"{ com.netflix.hystrix.contrib.networkauditor.HystrixNetworkAuditorAgent.handleNetworkEvent(); }\");\n                    }\n                }\n            } catch (Exception e) {\n                throw new RuntimeException(\"Failed trying to wrap method [\" + method.getName() + \"] of class: \" + className, e);\n            }\n        }\n        return ctClazz.toBytecode();\n    }\n\n}","sourceCodeStart":91,"sourceCodeEnd":115,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-contrib/hystrix-network-auditor-agent/src/main/java/com/netflix/hystrix/contrib/networkauditor/NetworkClassTransform.java#L91-L115","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"# before\njava -javaagent:hystrix-network-auditor-agent-1.5.x.jar -jar app.jar\n# after\n# pin matching versions and exclude the failing class\njava -javaagent:hystrix-network-auditor-agent-1.5.x.jar=excludedClasses=com.example.ProblemClass -jar app.jar","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"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.","preventionTips":["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"],"tags":["java","javaagent","bytecode","javassist","network-auditor"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}