Solution to java.lang.NoSuchMethodException for org.zkoss.zel.BeanELResolver.__resetCache() in ZKPlugin
ignaciomarinreyes opened this issue · 1 comments
I encountered a NoSuchMethodException while upgrading from ZK Framework version 5.0.9 to 9.6.0.1, using HotSwap Agent 1.4.1, Java 1.8.0_121, and transitioning from Tomcat 8.5 to Tomcat 9. The error occurred as follows:
java.lang.NoSuchMethodException: org.zkoss.zel.BeanELResolver.__resetCache() at java.lang.Class.getDeclaredMethod(Class.java:2130) at org.hotswap.agent.plugin.zk.ZkPlugin$1.executeCommand(ZkPlugin.java:154) at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:43)
The method __resetCache() does not exist in the new ZK version. This problem arises because, in ZK 5.0.9, ConcurrentCache was an inner class of BeanELResolver. In ZK 9.6.0.1, it has been relocated and is no longer an inner class but a standalone class in a different package.
To resolve this reflection issue, the reference to ConcurrentCache needs to be updated in the source code. Here's the required change in the code:
this.cache = new org.zkoss.zel.BeanELResolver.ConcurrentCache(CACHE_SIZE);
this.cache = new org.zkoss.zel.impl.util.ConcurrentCache(CACHE_SIZE);
By updating the package path, the reflection mechanism can successfully locate and utilize the ConcurrentCache class, allowing the __resetCache method to be added without triggering a NoSuchMethodException.
This change ensures that the application remains compatible with the structural changes in the ZK Framework between versions 5 and 9.
In ZK9 HotSwap Agent 1.4.1 doesn´t work, you have to make this change and it works. You have to reset the cache.
Could you, please, create PR?