InvocationTargetException异常分析

java.lang.reflect.InvocationTargetException

InvocationTargetException异常分析_第1张图片

报此异常,是该方法内try {}catch(){抛出异常e.printStackTrace()},或者调用远程服务器所导致的一样:例如:

InvocationTargetException异常分析_第2张图片

总结以下导致原因;

1.远程代码ip加端口获取远程跨服拒绝连接和服务器未启动所导致的,是由调用方法或构造方法所抛出异常的受检查的异常.

2.有可能web项目下的jar包缺失导致,,详细检查控制台报出的异常日志信息,再对应查找相关jar包.或重复包

3.在本机电脑测试出没有问题,打出war包确在war包运行服上报此异常, 请检查tomcat服务器版本,做好一致,或者war包服高于本服.

4.开发jdk和部署jdk版本不一致,导致InvocationTargetException异常信息返回一个空值。调用不上重写的方法

如果发生此异常!请不要慌张.如果我点web页面,发生此异常他的报错信息如下:

java.lang.reflect.InvocationTargetException: [[email protected]]Error happended: POST /game-admin/queryServer/getServerData->Object getServerData(int) params=[0]
net.paoding.rose.web.impl.thread.ActionEngine.createException(ActionEngine.java:426)
net.paoding.rose.web.impl.thread.ActionEngine.execute(ActionEngine.java:308)
net.paoding.rose.web.impl.thread.LinkedEngine.execute(LinkedEngine.java:60)
net.paoding.rose.web.impl.thread.Rose.doNext(Rose.java:121)
net.paoding.rose.web.impl.thread.ControllerEngine.execute(ControllerEngine.java:83)
net.paoding.rose.web.impl.thread.LinkedEngine.execute(LinkedEngine.java:60)
net.paoding.rose.web.impl.thread.Rose.doNext(Rose.java:121)
net.paoding.rose.web.impl.thread.ModuleEngine.innerInvoke(ModuleEngine.java:122)
net.paoding.rose.web.impl.thread.ModuleEngine.execute(ModuleEngine.java:112)
net.paoding.rose.web.impl.thread.LinkedEngine.execute(LinkedEngine.java:60)
net.paoding.rose.web.impl.thread.Rose.doNext(Rose.java:121)
net.paoding.rose.web.impl.thread.RootEngine.execute(RootEngine.java:126)
net.paoding.rose.web.impl.thread.LinkedEngine.execute(LinkedEngine.java:60)
net.paoding.rose.web.impl.thread.Rose.doNext(Rose.java:121)
net.paoding.rose.web.impl.thread.Rose.innerStart(Rose.java:250)
net.paoding.rose.web.impl.thread.Rose.start(Rose.java:109)
net.paoding.rose.RoseFilter.doFilter(RoseFilter.java:332)
root cause
java.lang.reflect.InvocationTargetException
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
net.paoding.rose.web.impl.thread.ActionEngine$InvocationChainImpl.doNext(ActionEngine.java:398)
net.paoding.rose.web.ControllerInterceptorAdapter.round(ControllerInterceptorAdapter.java:136)
net.paoding.rose.web.ControllerInterceptorAdapter.roundInvocation(ControllerInterceptorAdapter.java:104)
net.paoding.rose.web.InterceptorDelegate.roundInvocation(InterceptorDelegate.java:103)
net.paoding.rose.web.impl.thread.ActionEngine$InvocationChainImpl.doNext(ActionEngine.java:383)
net.paoding.rose.web.impl.thread.ActionEngine.innerExecute(ActionEngine.java:360)
net.paoding.rose.web.impl.thread.ActionEngine.execute(ActionEngine.java:306)
net.paoding.rose.web.impl.thread.LinkedEngine.execute(LinkedEngine.java:60)
net.paoding.rose.web.impl.thread.Rose.doNext(Rose.java:121)
net.paoding.rose.web.impl.thread.ControllerEngine.execute(ControllerEngine.java:83)
net.paoding.rose.web.impl.thread.LinkedEngine.execute(LinkedEngine.java:60)
net.paoding.rose.web.impl.thread.Rose.doNext(Rose.java:121)
net.paoding.rose.web.impl.thread.ModuleEngine.innerInvoke(ModuleEngine.java:122)
net.paoding.rose.web.impl.thread.ModuleEngine.execute(ModuleEngine.java:112)
net.paoding.rose.web.impl.thread.LinkedEngine.execute(LinkedEngine.java:60)
net.paoding.rose.web.impl.thread.Rose.doNext(Rose.java:121)
net.paoding.rose.web.impl.thread.RootEngine.execute(RootEngine.java:126)
net.paoding.rose.web.impl.thread.LinkedEngine.execute(LinkedEngine.java:60)
net.paoding.rose.web.impl.thread.Rose.doNext(Rose.java:121)
net.paoding.rose.web.impl.thread.Rose.innerStart(Rose.java:250)
net.paoding.rose.web.impl.thread.Rose.start(Rose.java:109)
net.paoding.rose.RoseFilter.doFilter(RoseFilter.java:332)
root cause


com.caucho.hessian.client.HessianRuntimeException: java.net.ConnectException: Connection refused: connect
com.caucho.hessian.client.HessianProxy.sendRequest(HessianProxy.java:281)
com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:171)
com.sun.proxy.$Proxy42.getQueryServerData(Unknown Source)

这是页面上面在服务器上反馈回来的页面信息;上面可以看出这是post请求,Connection refused: connect服务器拒绝连接.所导致.

在开发过程中,如果以上解释还未解决这个InvocationTargetException异常报错信息.

还有一个大招,大家都知道异常类的最父类是Exception.

InvocationTargetException异常分析_第3张图片

请把你包此方法的try catch异常抛出变成父类,就如愿以偿的解决了此问题!然后在抛出中加入日志提示.


你可能感兴趣的:(InvocationTargetException异常分析)