一个很细微的异常java.lang.reflect.InvocationTargetException
今天做的一个项目的过程中,突然出现出现这样的一个错误
type Exception reportmessagedescription The server encountered an internal error () that prevented it from fulfilling this request.exceptionjava.lang.reflect.InvocationTargetExceptionsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)java.lang.reflect.Method.invoke(Method.java:597)com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)....//中间一部分代码省略掉了root causejava.lang.NoClassDefFoundError: Could not initialize class com.db.HibernateUtilcom.dao.DeptDao.queryDepts(DeptDao.java:28)com.dao.DeptDao.isLeaf(DeptDao.java:63)com.web.DeptTreeAction.deptEmps(DeptTreeAction.java:92)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)java.lang.reflect.Method.invoke(Method.java:597)com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280).....//部分代码省略掉了
??? 起初并不知道是什么,因为这里面显示的是
com.db.HibernateUtil
??? 这个自己写的类的问题,我感觉不对,因为我今天没有去改过,还是好好的
? ? 网上查了好久没有找到解决的办法。
??? 很多人说是导包的问题,或是Tomcat的问题
?
??? 所有的数据库操作都出现问题,就直接不用前台的交互,用自己的Junit写的测试类来测,发现
java.lang.ExceptionInInitializerErrorat com.dao.DeptDao.queryDepts(DeptDao.java:28)at test.DeptTest.deptTest(DeptTest.java:16)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)at org.junit.runners.ParentRunner.run(ParentRunner.java:220)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/model/NoteInfo.hbm.xmlat org.hibernate.cfg.Configuration.addResource(Configuration.java:602)at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1621)at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1589)at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1568)at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1542)at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)at org.hibernate.cfg.Configuration.configure(Configuration.java:1448)at com.db.HibernateUtil.<clinit>(HibernateUtil.java:18)... 26 moreCaused by: org.hibernate.PropertyNotFoundException: field [receiversId] not found on com.model.NoteInfoat org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:145)at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:137)at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:160)at org.hibernate.util.ReflectHelper.getter(ReflectHelper.java:106)at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:94)at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:302)at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2193)at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2170)at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2060)at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:381)at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)at org.hibernate.cfg.Configuration.add(Configuration.java:702)at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:537)at org.hibernate.cfg.Configuration.addResource(Configuration.java:599)... 33 more
??? 从这里,很清楚的找到了问题的所在
?? 出现问题的地方是:因为今天在jodo中,被我改了一个属性的名字,映射文件忘记改过了而导致的
?
?? 我在想出现这种问题的原因应该很多,但我这里写的也只是我自己碰到的问题,也提供个参改吧。呵呵
?
?
?