apache/shenyu · error · ShenyuException

The plugin JAR file is not correct or exceeds 16MB!

Error message

The plugin JAR file is not correct or exceeds 16MB!

What it means

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!'.

Solutions

  1. Verify the JAR opens as a valid zip and is under 16MB before calling getDependencyTree (e.g. check size and test with JarFile).
  2. Rebuild the plugin JAR with a correct Maven shade/assembly configuration and re-upload.
  3. Increase the size limit constant if 16MB is legitimately too small, after validating server resources.
  4. Log/inspect the wrapped cause (LOG shows 'get dependency tree error') to identify the real parse failure.

Example fix

// before
File f = new File(path);
DependencyNode tree = JarDependencyUtils.getDependencyTree(f);
// after
File f = new File(path);
if (f.length() > 16 * 1024 * 1024 || !isValidJar(f)) {
    throw new IllegalArgumentException("plugin jar invalid or exceeds 16MB");
}
DependencyNode tree = JarDependencyUtils.getDependencyTree(f);
Defensive patterns

Strategy: validation

Validate before calling

if (jarFile.length() > 16L * 1024 * 1024) throw new IllegalArgumentException("plugin jar exceeds 16MB");
try (JarFile jf = new JarFile(jarFile)) { } catch (IOException e) { throw new IllegalArgumentException("not a valid jar"); }

Try / catch

try { tree = JarDependencyUtils.getDependencyTree(jar); } catch (ShenyuException e) { LOG.error("invalid plugin jar: {}", e.getMessage()); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/a42d65b02be3c7b4. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-common/src/main/java/org/apache/shenyu/common/utils/JarDependencyUtils.java:84

                    for (String interfaceName : classNode.interfaces) {
                        addDependencies(interfaceName, dependencies);
                    }
                    for (FieldNode fieldNode : classNode.fields) {
                        addDependencies(Type.getType(fieldNode.desc).getClassName(), dependencies);
                    }
                    for (MethodNode methodNode : classNode.methods) {
                        addDependencies(Type.getReturnType(methodNode.desc).getClassName(), dependencies);
                        for (Type argumentType : Type.getArgumentTypes(methodNode.desc)) {
                            addDependencies(argumentType.getClassName(), dependencies);
                        }
                    }
                }
            }
            return dependencies;

        } catch (Exception e) {
            LOG.error("get dependency tree error", e);
            throw new ShenyuException(AdminConstants.THE_PLUGIN_JAR_FILE_IS_NOT_CORRECT_OR_EXCEEDS_16_MB);
        }
    }

    /**
     * Add dependencies.
     * @param typeName type name
     * @param dependencies dependencies
     */
    private static void addDependencies(final String typeName, final Set<String> dependencies) {
        if (!typeName.startsWith("java") && !typeName.startsWith("javax")) {
            dependencies.add(typeName.replace("/", "."));
        }
    }
}

View on GitHub (pinned to 567142e072)