{"record":{"id":"a42d65b02be3c7b4","repo":"apache/shenyu","slug":"the-plugin-jar-file-is-not-correct-or-exceeds-16mb","errorCode":null,"errorMessage":"The plugin JAR file is not correct or exceeds 16MB!","messagePattern":"The plugin JAR file is not correct or exceeds 16MB!","errorType":"exception","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-common/src/main/java/org/apache/shenyu/common/utils/JarDependencyUtils.java","lineNumber":84,"sourceCode":"                    for (String interfaceName : classNode.interfaces) {\n                        addDependencies(interfaceName, dependencies);\n                    }\n                    for (FieldNode fieldNode : classNode.fields) {\n                        addDependencies(Type.getType(fieldNode.desc).getClassName(), dependencies);\n                    }\n                    for (MethodNode methodNode : classNode.methods) {\n                        addDependencies(Type.getReturnType(methodNode.desc).getClassName(), dependencies);\n                        for (Type argumentType : Type.getArgumentTypes(methodNode.desc)) {\n                            addDependencies(argumentType.getClassName(), dependencies);\n                        }\n                    }\n                }\n            }\n            return dependencies;\n\n        } catch (Exception e) {\n            LOG.error(\"get dependency tree error\", e);\n            throw new ShenyuException(AdminConstants.THE_PLUGIN_JAR_FILE_IS_NOT_CORRECT_OR_EXCEEDS_16_MB);\n        }\n    }\n\n    /**\n     * Add dependencies.\n     * @param typeName type name\n     * @param dependencies dependencies\n     */\n    private static void addDependencies(final String typeName, final Set<String> dependencies) {\n        if (!typeName.startsWith(\"java\") && !typeName.startsWith(\"javax\")) {\n            dependencies.add(typeName.replace(\"/\", \".\"));\n        }\n    }\n}\n","sourceCodeStart":66,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-common/src/main/java/org/apache/shenyu/common/utils/JarDependencyUtils.java#L66-L99","documentation":"JarDependencyUtils.getDependencyTree analyzes an uploaded plugin JAR to build its dependency tree. Any failure during parsing/reading the JAR (corrupt file, not a real zip, oversized >16MB) is caught and rethrown as ShenyuException with the AdminConstants message 'The plugin JAR file is not correct or exceeds 16MB!'.","triggerScenarios":"Calling getDependencyTree on a file that is not a valid JAR/zip, a truncated download, or a JAR larger than the 16MB limit; missing nested POM/dependency metadata that the analyzer expects.","commonSituations":"Uploading a plugin package through the admin plugin-upload UI with a corrupted or oversized file; renaming a non-jar file to .jar; network truncation during upload; building the plugin with a broken shade configuration.","solutions":["Verify the JAR opens as a valid zip and is under 16MB before calling getDependencyTree (e.g. check size and test with JarFile).","Rebuild the plugin JAR with a correct Maven shade/assembly configuration and re-upload.","Increase the size limit constant if 16MB is legitimately too small, after validating server resources.","Log/inspect the wrapped cause (LOG shows 'get dependency tree error') to identify the real parse failure."],"exampleFix":"// before\nFile f = new File(path);\nDependencyNode tree = JarDependencyUtils.getDependencyTree(f);\n// after\nFile f = new File(path);\nif (f.length() > 16 * 1024 * 1024 || !isValidJar(f)) {\n    throw new IllegalArgumentException(\"plugin jar invalid or exceeds 16MB\");\n}\nDependencyNode tree = JarDependencyUtils.getDependencyTree(f);","handlingStrategy":"validation","validationCode":"if (jarFile.length() > 16L * 1024 * 1024) throw new IllegalArgumentException(\"plugin jar exceeds 16MB\");\ntry (JarFile jf = new JarFile(jarFile)) { } catch (IOException e) { throw new IllegalArgumentException(\"not a valid jar\"); }","typeGuard":null,"tryCatchPattern":"try { tree = JarDependencyUtils.getDependencyTree(jar); } catch (ShenyuException e) { LOG.error(\"invalid plugin jar: {}\", e.getMessage()); }","preventionTips":["Check file size before upload (client and server side)","Verify JAR integrity (zip magic, openable JarFile) before analysis","Keep shade plugin config correct so JARs are valid","Log the root cause when wrapping into ShenyuException"],"tags":["jar","plugin-upload","file-size","validation"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}