我有这样的事情:
StudentBean.java
@PersistenceContext
EntityManager em;
@Override
public Boolean addStudent(Student s) {
try{
// Student s1 = new Student(10,"asd", "asd"); //this was for testing
em.persist(s);
em.flush();
} catch (Exception ex) {
ex.printStackTrace();
}
return true;
}
然后我用这个构造函数得到了Student.java:
public Student(Integer studentId, String firstName, String lastName) {
this();
this.studentId = studentId;
this.firstName = firstName;
this.lastName = lastName;
}
我有一个UTest.java类用于测试函数... 我得到了这个:
@Test public void testAddStudent() {
StudentBean sb = new StudentBean();
Student s1 = new Student(4, "Ognjen", "Car");
System.out.println(s1.toString()); //it does not print anything
Boolean s = sb.addStudent(s1);
assert (s == true);
// fail("Not yet implemented");
}
当我运行测试时,它会显示此错误,而我根本无法找到答案,请帮助
java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:166)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:103)
at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:114)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:162)
... 9 more
Caused by: java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.core.impl.ManagerImpl
at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:166)
at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:103)
at org.jboss.arquillian.core.spi.ManagerBuilder.create(ManagerBuilder.java:77)
at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:62)
... 14 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:162)
... 17 more
Caused by: java.lang.NoClassDefFoundError: org/jboss/shrinkwrap/descriptor/api/Descriptor
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$100(Unknown Source)
at java.net.URLClassLoader$1.run(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.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$100(Unknown Source)
at java.net.URLClassLoader$1.run(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.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.jboss.arquillian.core.impl.SecurityActions$1.run(SecurityActions.java:188)
at org.jboss.arquillian.core.impl.SecurityActions$1.run(SecurityActions.java:185)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.arquillian.core.impl.SecurityActions.getConstructor(SecurityActions.java:184)
at org.jboss.arquillian.core.impl.SecurityActions.newInstance(SecurityActions.java:158)
at org.jboss.arquillian.core.impl.Reflections.createInstance(Reflections.java:122)
at org.jboss.arquillian.core.impl.ManagerImpl.createExtensions(ManagerImpl.java:440)
at org.jboss.arquillian.core.impl.ManagerImpl.fireProcessing(ManagerImpl.java:375)
at org.jboss.arquillian.core.impl.ManagerImpl.<init>(ManagerImpl.java:100)
... 22 more
Caused by: java.lang.ClassNotFoundException: org.jboss.shrinkwrap.descriptor.api.Descriptor
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)
... 59 more
这也是一张图片