我正在使用JBoss AS 7.1
构建应用程序,我正在编写测试
@Test
public void testGetLoginUser() throws Exception {
final MarketCrudService crudService = new MarketCrudService(jpaRule.getEntityManager());
crudService.create(new Login("user1", "password"));
}
此测试取决于创建的@Rule
,其中in-memory derby db
用于编写测试数据
当我运行此测试时,我看到以下错误
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/transaction/SystemException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
at org.hibernate.ejb.Ejb3Configuration.<clinit>(Ejb3Configuration.java:141)
... snipped
这发生在
行emFactory = Persistence.createEntityManagerFactory(persistenceUnitName, persistenceProperties);
我用Google搜索并发现这是因为jta.jar
丢失了,所以在pom.xml
我添加了
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.1_spec</artifactId>
<version>1.0.1.Final</version>
</dependency>
再次跑步并没有解决问题,我该如何解决?
答案 0 :(得分:1)
添加此解决了问题
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.1_spec</artifactId>
</dependency>