spring-projects/spring-framework · critical · IllegalStateException
The version of aspectjtools.jar / aspectjweaver.jar on the c
Error message
The version of aspectjtools.jar / aspectjweaver.jar on the classpath is incompatible with this version of Spring: {} What it means
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.
Source
Thrown at spring-aop/src/main/java/org/springframework/aop/aspectj/RuntimeTestWalker.java:76
* @since 2.0
*/
class RuntimeTestWalker {
private static final Field residualTestField;
private static final Field varTypeField;
private static final Field myClassField;
static {
try {
residualTestField = ShadowMatchImpl.class.getDeclaredField("residualTest");
varTypeField = ReflectionVar.class.getDeclaredField("varType");
myClassField = ReflectionBasedReferenceTypeDelegate.class.getDeclaredField("myClass");
}
catch (NoSuchFieldException ex) {
throw new IllegalStateException("The version of aspectjtools.jar / aspectjweaver.jar " +
"on the classpath is incompatible with this version of Spring: " + ex);
}
}
private final @Nullable Test runtimeTest;
public RuntimeTestWalker(ShadowMatch shadowMatch) {
try {
ReflectionUtils.makeAccessible(residualTestField);
this.runtimeTest = (Test) residualTestField.get(shadowMatch);
}
catch (IllegalAccessException ex) {
throw new IllegalStateException(ex);
}
}
View on GitHub (pinned to e8729d0438)
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.
Example fix
<!-- before: conflicting aspectjweaver pulled transitively -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>6.1.0</version>
</dependency>
<!-- old aspectjweaver 1.8.x from somewhere -->
<!-- after: align via BOM -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>6.1.0</version>
<type>pom</type><scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> Defensive patterns
Strategy: validation
Validate before calling
// Verify aspectjweaver version matches Spring's expectation at startup:
String v = org.aspectj.weaver.Version.text;
assert v.contains("1.9.") : "Unexpected AspectJ version: " + v;
// Prefer BOM-managed dependency to avoid manual checks. Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Returning name '{}' is neither a valid argument name nor the
- Throwing name '{}' is neither a valid argument name nor the
- MethodInvocation is not a Spring ProxyMethodInvocation: {}
- 'argumentNames' property of AbstractAspectJAdvice contains a
- Only afterReturning advice can be used to bind a return valu
AI-assisted analysis of spring-projects/spring-framework@e8729d0438 (2026-08-04).
Data as JSON: /data/errors/afa7047603d7ada7.json.
Report an issue: GitHub.