integration-testingwildflycdientitymanagerjboss-arquillian

Integration-Test: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor


I want to create a integration test against a database and clean it up afterwards in an wildfly/arquillian environment. But when I try to execute the Test I get a Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor. I use junit and I implemented following code according to this site for my Integration Test:

@RunWith(Arquillian.class)
public class MyFirstIT{


    @Deployment
    public static JavaArchive createTestArchive() {
        return ShrinkWrap.create(JavaArchive.class, "test.jar")
            .addClasses(EntityManager.class)
            .addAsManifestResource(
                EmptyAsset.INSTANCE,
                ArchivePaths.create("beans.xml"));
    }

    @PersistenceContext
    private EntityManager myEntityManager;

    @BeforeAll
    public static void setup() {...}

    @Test
    public void createInstanceTest() {

        // ... Testing Code redacted
        // ...

        var myClass = myEntityManager.find(MyClass.class ,"1");
    }
}

My beans.xml is defined as:

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
       bean-discovery-mode="all">
</beans>

My pom,xml includes:

<dependency>
    <groupId>org.jboss.arquillian</groupId>
    <artifactId>arquillian-bom</artifactId>
    <version>1.1.13.Final</version>
    <scope>import</scope>
    <type>pom</type>
</dependency>
<dependency>
    <groupId>org.glassfish.main.extras</groupId>
    <artifactId>glassfish-embedded-all</artifactId>
    <version>4.1.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
    <version>1.0.0.Final</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
</dependency>
<dependency>
    <groupId>org.wildfly.security</groupId>
    <artifactId>wildfly-elytron-util</artifactId>
    <version>2.1.0.Final</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.testng</groupId>
    <artifactId>arquillian-testng-core</artifactId>
    <version>1.7.0.Final</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.junit</groupId>
    <artifactId>arquillian-junit-core</artifactId>
    <version>1.9.1.Final</version>
    <scope>test</scope>
</dependency>

This configuration doesn't seem to work. I don't know what I am missing, what I might need to add, if I'm doing something wrong or if this is not possible at all.

Other people seem to have had the same problem but the post is from 2014. Maybe the solution is deprecated?

I would appreciate any help.


Solution

  • The org.jboss.arquillian:arquillian-bom version you are using is from 2017 - https://mvnrepository.com/artifact/org.jboss.arquillian/arquillian-bom - while the org.jboss.arquillian.junit:arquillian-junit-core is recent. So the classpath misalignment is very likely the culprit.

    Also, obtain complete stacktraces and try running maven with -X,--debug for more debug information.