欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java.lang.reflect.InvocationTargetException

程序员文章站 2024-01-10 14:58:40
...

错误信息

先贴出我的错误信息:

Exception

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	com.yxy.servlet.BaseServlet.service(BaseServlet.java:64)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause

java.lang.reflect.InvocationTargetException
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:567)
	com.yxy.servlet.BaseServlet.service(BaseServlet.java:48)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause

java.lang.NoClassDefFoundError: org/apache/commons/collections/FastHashMap
	org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:964)
	org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:935)
	org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:823)
	org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:431)
	com.yxy.commons.CommonUtils.toBean(CommonUtils.java:24)
	com.yxy.cstm.web.servlet.CustomerServlet.add(CustomerServlet.java:20)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:567)
	com.yxy.servlet.BaseServlet.service(BaseServlet.java:48)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause

java.lang.ClassNotFoundException: org.apache.commons.collections.FastHashMap
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
	org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:964)
	org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:935)
	org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:823)
	org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:431)
	com.yxy.commons.CommonUtils.toBean(CommonUtils.java:24)
	com.yxy.cstm.web.servlet.CustomerServlet.add(CustomerServlet.java:20)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:567)
	com.yxy.servlet.BaseServlet.service(BaseServlet.java:48)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

经过反复测试发现是在使用beanUtils的populate将map中的属性封装到javabean对象时抛出了RuntimeException异常,导致程序执行中断,发现是没有导入BeanUtils的依赖jar包:我的是:Commons-connections-3.22.导入了后项目就正常运行了.

这个世界上没有跨不过的坎儿,加油!!!