今天碰到一个奇怪的问题,本地Eclipse起了一个tomcat通过http去调一个外部接口,结果竟然报了一个反射的异常——java.lang.reflect.InvocationTargetException,从日志里看不出啥来,通过eclipse调试发生了诡异的事情——直接跳入异常了
* Constructs a InvocationTargetException with a target exception.
*
* @param target the target exception
*/
public InvocationTargetException(Throwable target) {
super((Throwable)null); // Disallow initCause
this.target = target;
}
从异常看,是程序找不到调用代码了,但是eclipse里面是可以找到调用类和方法的。想了一下,应该是编译出问题了,或许class文件里没有应的代码。去eclipse部署的本地tomcat路径下找class:打开Servers窗口 -> 找到Server Locations,看Server path和Deploy path,进入本地部署路径:
![](https://i-blog.csdnimg.cn/blog_migrate/dda7cf20e080b82dab7de054b459d614.png)
进入wtpwebapps -> 进入war包 -> 找到引用的jar -> 打开jar包,根据包路径找类,果然没有调用类。估计是之前引用的jar包编译出了问题。
解决办法:重新编译问题jar包,刷新引用jar包的工程,最后clean一下tomcat,再次进入到tomcat本地部署路径E:\workspace.metadata.pluginsorg.eclipse.wst.server.core mp0wtpwebapps,发现调用类出现了,重新启动tomcat,问题依然存在。这就奇怪了,重新调试,发现另一个问题:
java.lang.NoSuchMethodError: io.netty.handler.ssl.SslContextBuilder.protocols([Ljava/lang/String;)Lio/netty/handler/ssl/SslContextBuilder;
有点摸不着头脑,代码调试时流程没变,直接跳入异常,但异常显示的