{"record":{"id":"d43d496d9f8e7c0e","repo":"xuxueli/xxl-job","slug":"xxl-glue-loadnewinstance-error-insta","errorCode":null,"errorMessage":">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null","messagePattern":">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"xxl-job-core/src/main/java/com/xxl/job/core/glue/GlueFactory.java","lineNumber":66,"sourceCode":"\t *\r\n\t * @param codeSource  code source\r\n\t * @return IJobHandler\r\n\t */\r\n\tpublic IJobHandler loadNewInstance(String codeSource) throws Exception{\r\n\t\tif (StringTool.isNotBlank(codeSource)) {\r\n\t\t\tClass<?> clazz = getCodeSourceClass(codeSource);\r\n\t\t\tif (clazz != null) {\r\n\t\t\t\tObject instance = clazz.newInstance();\r\n                if (instance instanceof IJobHandler) {\r\n                    this.injectService(instance);\r\n                    return (IJobHandler) instance;\r\n                } else {\r\n                    throw new IllegalArgumentException(\">>>>>>>>>>> xxl-glue, loadNewInstance error, \"\r\n                            + \"cannot convert from instance[\" + instance.getClass() + \"] to IJobHandler\");\r\n                }\r\n            }\r\n\t\t}\r\n\t\tthrow new IllegalArgumentException(\">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null\");\r\n\t}\r\n\tprivate Class<?> getCodeSourceClass(String codeSource){\r\n\t\ttry {\r\n\t\t\t// md5\r\n\t\t\tbyte[] md5 = MessageDigest.getInstance(\"MD5\").digest(codeSource.getBytes());\r\n\t\t\tString md5Str = new BigInteger(1, md5).toString(16);\r\n\r\n\t\t\tClass<?> clazz = CLASS_CACHE.get(md5Str);\r\n\t\t\tif(clazz == null){\r\n\t\t\t\tclazz = groovyClassLoader.parseClass(codeSource);\r\n\t\t\t\tCLASS_CACHE.putIfAbsent(md5Str, clazz);\r\n\t\t\t}\r\n\t\t\treturn clazz;\r\n\t\t} catch (Exception e) {\r\n\t\t\treturn groovyClassLoader.parseClass(codeSource);\r\n\t\t}\r\n\t}\r\n\r","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/xuxueli/xxl-job/blob/e74c784f68f81fa89cb350913ef15794865d7b12/xxl-job-core/src/main/java/com/xxl/job/core/glue/GlueFactory.java#L48-L84","documentation":"Thrown by GlueFactory.loadNewInstance as IllegalArgumentException when no glue instance could be produced: the codeSource was blank, or getCodeSourceClass returned null (e.g. Groovy parsing failed silently upstream). It is the fallback for any path that did not yield a class+instance.","triggerScenarios":"Calling loadNewInstance with a null/blank codeSource, or with source whose class failed to load (getCodeSourceClass returned null). The final throw fires because clazz remained null.","commonSituations":"Glue source cleared or never saved; a Groovy compile error left CLASS_CACHE empty for that md5; a stale/empty glue record triggered a reload.","solutions":["Provide non-blank, syntactically valid glue source before loading.","Check the admin console: ensure the glue script is saved and compiles (no Groovy syntax errors).","Verify getCodeSourceClass/groovyClassLoader.parseClass logs for the underlying compile failure."],"exampleFix":"// before\nfactory.loadNewInstance(\"\"); // blank source\n// after\nfactory.loadNewInstance(validGroovySource); // non-empty, compiling class","handlingStrategy":"validation","validationCode":"if (StringTool.isBlank(codeSource)) {\n    throw new IllegalArgumentException(\"glue codeSource is empty\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    IJobHandler h = glueFactory.loadNewInstance(codeSource);\n} catch (IllegalArgumentException e) {\n    log.error(\"glue load failed (no instance): {}\", e.getMessage());\n}","preventionTips":["Never load a blank/null glue source; guard before calling loadNewInstance.","Surface and fix Groovy compile errors shown in getCodeSourceClass logs.","Ensure the glue script is saved and non-empty in the admin console."],"tags":["glue","groovy","scripting","validation"],"backgroundTag":null,"analyzedSha":"e74c784f68f81fa89cb350913ef15794865d7b12","analyzedAt":"2026-08-14T04:22:43.715Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}