Before in SpringBoot version 3.1.5, everything worked well, but when I upgraded to version 3.2.0, the following code did not work:
public class SystemListener implements SpringApplicationRunListener {
@Override
public void ready(ConfigurableApplicationContext context, Duration timeTaken) {
context.publishEvent(new MyCustomEvent("1001"));
}
}
It throws the following exception:
org.springframework.expression.spel.SpelEvaluationException: EL1005E: Type cannot be found 'com.test.event.MyCustomEvent'
However, I did some debugging, the error occurred just in the following line of code in the StandardTypeLocator.java class
@Override
public Class<?> findType(String typeName) throws EvaluationException {
Class<?> cachedType = this.typeCache.get(typeName);
if (cachedType != null) {
return cachedType;
}
Class<?> loadedType = loadType(typeName);
////////////////////this line////////////////////
if (loadedType != null && !(this.classLoader instanceof SmartClassLoader scl && scl.isClassReloadable(loadedType))) {
this.typeCache.put(typeName, loadedType);
return loadedType;
}
throw new SpelEvaluationException(SpelMessage.TYPE_NOT_FOUND, typeName);
}
My JDK version: 21
Comment From: bclozel
@Bahramudin can you provide a minimal application that reproduces the problem? This might be linked to a particular classloader arrangement and it would be useful to reproduce the problem consistently.
This also could be a duplicate of https://github.com/spring-projects/spring-framework/issues/31668, can you change the « spring-framework.version » property in your build to test with 6.1.2-SNAPSHOT?
Comment From: snicoll
Thanks for the report, this is a duplicate of #31668
Comment From: Bahramudin
@bclozel Yes, I got it that is a duplicate. One of the solutions (remove dev-tools) also works for me, but I am waiting for this problem to officially get solved. Thanks the Spring Team!!