{"id":"afa7047603d7ada7","repo":"spring-projects/spring-framework","slug":"the-version-of-aspectjtools-jar-aspectjweaver-ja","errorCode":null,"errorMessage":"The version of aspectjtools.jar / aspectjweaver.jar on the classpath is incompatible with this version of Spring: {}","messagePattern":"The version of aspectjtools\\.jar / aspectjweaver\\.jar on the classpath is incompatible with this version of Spring: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"spring-aop/src/main/java/org/springframework/aop/aspectj/RuntimeTestWalker.java","lineNumber":76,"sourceCode":" * @since 2.0\n */\nclass RuntimeTestWalker {\n\n\tprivate static final Field residualTestField;\n\n\tprivate static final Field varTypeField;\n\n\tprivate static final Field myClassField;\n\n\n\tstatic {\n\t\ttry {\n\t\t\tresidualTestField = ShadowMatchImpl.class.getDeclaredField(\"residualTest\");\n\t\t\tvarTypeField = ReflectionVar.class.getDeclaredField(\"varType\");\n\t\t\tmyClassField = ReflectionBasedReferenceTypeDelegate.class.getDeclaredField(\"myClass\");\n\t\t}\n\t\tcatch (NoSuchFieldException ex) {\n\t\t\tthrow new IllegalStateException(\"The version of aspectjtools.jar / aspectjweaver.jar \" +\n\t\t\t\t\t\"on the classpath is incompatible with this version of Spring: \" + ex);\n\t\t}\n\t}\n\n\n\tprivate final @Nullable Test runtimeTest;\n\n\n\tpublic RuntimeTestWalker(ShadowMatch shadowMatch) {\n\t\ttry {\n\t\t\tReflectionUtils.makeAccessible(residualTestField);\n\t\t\tthis.runtimeTest = (Test) residualTestField.get(shadowMatch);\n\t\t}\n\t\tcatch (IllegalAccessException ex) {\n\t\t\tthrow new IllegalStateException(ex);\n\t\t}\n\t}\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/aspectj/RuntimeTestWalker.java#L58-L94","documentation":"Thrown from the static initializer of RuntimeTestWalker when it cannot find expected private fields (residualTest, varType, myClass) on AspectJ's internal classes (ShadowMatchImpl, ReflectionVar, ReflectionBasedReferenceTypeDelegate). This means the aspectjweaver/aspectjtools version on the classpath is incompatible with the Spring version in use — the internal field layout changed between AspectJ releases.","triggerScenarios":"Having an older or newer aspectjweaver/aspectjtools jar that does not match the version Spring was compiled and tested against; transitive dependency overriding the AspectJ version; mixing Spring 6.x with an AspectJ 1.8 jar (or vice versa).","commonSituations":"Upgrading Spring without upgrading AspectJ; a third-party library pulling in an old aspectjweaver; runtime classpath differs from build classpath; Spring Boot starter version mismatch.","solutions":["Align the AspectJ version with what the Spring version expects (check Spring's gradle.properties / bom for the matched aspectjVersion).","Use Spring's dependency management / BOM (spring-framework-bom or spring-boot-dependencies) to pin a compatible aspectjweaver version.","Run mvn dependency:tree or gradle dependencies to find and exclude conflicting aspectj jars.","Ensure only one aspectjweaver version is on the classpath."],"exampleFix":"<!-- before: conflicting aspectjweaver pulled transitively -->\n<dependency>\n  <groupId>org.springframework</groupId>\n  <artifactId>spring-aop</artifactId>\n  <version>6.1.0</version>\n</dependency>\n<!-- old aspectjweaver 1.8.x from somewhere -->\n\n<!-- after: align via BOM -->\n<dependencyManagement>\n  <dependencies>\n    <dependency>\n      <groupId>org.springframework</groupId>\n      <artifactId>spring-framework-bom</artifactId>\n      <version>6.1.0</version>\n      <type>pom</type><scope>import</scope>\n    </dependency>\n  </dependencies>\n</dependencyManagement>","handlingStrategy":"validation","validationCode":"// Verify aspectjweaver version matches Spring's expectation at startup:\nString v = org.aspectj.weaver.Version.text;\nassert v.contains(\"1.9.\") : \"Unexpected AspectJ version: \" + v;\n// Prefer BOM-managed dependency to avoid manual checks.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use spring-framework-bom or spring-boot-dependencies to pin the compatible aspectjweaver version.","Run mvn dependency:tree / gradle dependencies to detect conflicting aspectj jars.","Exclude transitive aspectjweaver overrides from third-party libraries.","Keep Spring and AspectJ versions upgraded together."],"tags":["spring-aop","aspectj","classpath","version-conflict","dependency"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}