HotswapProjects / HotswapAgent

Java unlimited redefinition of classes at runtime.
GNU General Public License v2.0
2.35k stars 493 forks source link

IllegalArgumentException no such field on tomcat 7.0.77 startup. #215

Open egor000 opened 7 years ago

egor000 commented 7 years ago

During init hotswap agent throws illegal state exception, no field repositories found for WebappClassLoader.

Root cause: TomcatPlugin is trying to set repository property of org.apache.catalina.loader.WebappClassLoader tomcat class with org.hotswap.agent.util.ReflectionHelper#set method. But in 7.0.77 version, they did refactoring and introduce parent class WebappClassLoaderBase for WebappClassLoader, moved repository property in it.
Current logic of ReflectionHelper#set will work only if field in current class, not in it's parent. Field field = clazz.getDeclaredField(fieldName);

Also please note, that seems from https://tomcat.apache.org/tomcat-8.0-doc/api/index.html and later, they remove ;repositories; field at all.

Nick-The-Uncharted commented 6 years ago

Fixed in fa5f227, please try the newest build mvn package --Dmaven.test.skip