java.lang.reflect.InvocationTargetException 异常解决方法

时间:2021-03-21 19:53:42

在做djunit测试的时候,发生下面异常:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at jp.co.dgic.testing.common.DJUnitClassLoader.getModifiedClass(DJUnitClassLoader.java:106)
at jp.co.dgic.testing.common.DJUnitClassLoader.findClass(DJUnitClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:653)
at jp.co.dgic.testing.common.DJUnitClassLoader.loadClass(DJUnitClassLoader.java:45)
at jp.co.dgic.testing.common.DJUnitEclipseClassLoader.loadClass(DJUnitEclipseClassLoader.java:59)
at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:425)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at jp.co.dgic.eclipse.jdt.internal.junit.runner.DJUnitRunner.main(DJUnitRunner.java:49)
Caused by: java.io.IOException: Class not found
at org.objectweb.asm.ClassReader.a(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at jp.co.dgic.testing.common.AsmClassModifier.getModifiedClass(AsmClassModifier.java:49)
... 21 more
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at jp.co.dgic.testing.common.DJUnitClassLoader.getModifiedClass(DJUnitClassLoader.java:106)
at jp.co.dgic.testing.common.DJUnitClassLoader.findClass(DJUnitClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:653)
at jp.co.dgic.testing.common.DJUnitClassLoader.loadClass(DJUnitClassLoader.java:45)
at jp.co.dgic.testing.common.DJUnitEclipseClassLoader.loadClass(DJUnitEclipseClassLoader.java:59)
at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:425)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at jp.co.dgic.eclipse.jdt.internal.junit.runner.DJUnitRunner.main(DJUnitRunner.java:49)
Caused by: java.io.IOException: Class not found
at org.objectweb.asm.ClassReader.a(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at jp.co.dgic.testing.common.AsmClassModifier.getModifiedClass(AsmClassModifier.java:49)
... 21 more
java.lang.Error: djUnit class load error (Class : co.jp.*******************************************.java)
at jp.co.dgic.testing.common.DJUnitClassLoader.findClass(DJUnitClassLoader.java:59)
at java.lang.ClassLoader.loadClass(ClassLoader.java:653)
at jp.co.dgic.testing.common.DJUnitClassLoader.loadClass(DJUnitClassLoader.java:45)
at jp.co.dgic.testing.common.DJUnitEclipseClassLoader.loadClass(DJUnitEclipseClassLoader.java:59)
at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:425)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at jp.co.dgic.eclipse.jdt.internal.junit.runner.DJUnitRunner.main(DJUnitRunner.java:49)

发生原因:找到class相应路径下,对应的class文件没生成,有可能是某些class有错,导致没有完成编译,在clean后,经常发生。

解决方法:properties属性里的 java   compiler--> building --> ビルド・パスの問題 --> 

                  abort   build   when   build   path     errors   occur / ビルド・パス・エラーの発生時にビルドを中断  前面的勾去掉