1

I am building an application using JBoss AS 7.1 and I am writing a test

@Test
    public void testGetLoginUser() throws Exception {
        final MarketCrudService crudService = new MarketCrudService(jpaRule.getEntityManager());
        crudService.create(new Login("user1", "password"));
    }

This test depends on @Rule created which instantiates a in-memory derby db for writing test data
When I run this test, I see following error

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

This happens at line

emFactory = Persistence.createEntityManagerFactory(persistenceUnitName, persistenceProperties);

I googled and found out the this is because jta.jar is missing, so in my pom.xml I added

   <dependency>
        <groupId>org.jboss.spec.javax.transaction</groupId>
        <artifactId>jboss-transaction-api_1.1_spec</artifactId>
        <version>1.0.1.Final</version>
    </dependency>

Running again did not solved the problem, how can I fix it?

daydreamer
  • 87,243
  • 191
  • 450
  • 722

1 Answers1

2

Adding this resolved the issue

       <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.1_spec</artifactId>
        </dependency>
daydreamer
  • 87,243
  • 191
  • 450
  • 722