ssh junit4报错

SSh整合后,使用Spring的TestContext测试框架,出现如下问题
java.lang.TypeNotPresentException: Type [unknown] not present
at sun.reflect.annotation.TypeNotPresentExceptionProxy.generateException(Unknown Source)
at sun.reflect.annotation.AnnotationInvocationHandler.invoke(Unknown Source)
at $Proxy5.value(Unknown Source)
at org.junit.internal.requests.ClassRequest.getRunnerClass(ClassRequest.java:49)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:28)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.<init>(JUnit4TestMethodReference.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30)
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)
Caused by: java.lang.NoClassDefFoundError: org/junit/internal/runners/JUnit4ClassRunner
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(Unknown Source)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Unknown Source)
at sun.reflect.generics.tree.ClassTypeSignature.accept(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseSig(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseClassValue(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown Source)
at java.lang.Class.initAnnotationsIfNecessary(Unknown Source)
at java.lang.Class.initAnnotationsIfNecessary(Unknown Source)
at java.lang.Class.initAnnotationsIfNecessary(Unknown Source)
at java.lang.Class.getAnnotation(Unknown Source)
at org.junit.internal.requests.ClassRequest.getRunnerClass(ClassRequest.java:45)
... 10 more
Caused by: java.lang.ClassNotFoundException: org.junit.internal.runners.JUnit4ClassRunner
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 38 more

解决问题:

因为spring的测试框架需要junit4.4版本以上的包,所以把MyEclipse6.5自带的junit4 这个版本的junit删除掉,然后倒入自己的包junit4.5,问题就能解决。

这是因为spring 2.5的版本必须用junit4.4版本以上的包,在搭ssh框架的时候,要注意包版本的正确性。

记录以学习

你可能感兴趣的:(java,eclipse,ssh,JUnit,sun)