I
I
iAlex1952021-07-30 11:38:48
Java
iAlex195, 2021-07-30 11:38:48

Why won't the test run using the EJBContainer?

When I try to run the test using EJBContainer.createEJBContainer(properties) I get the error: "jakarta.ejb.EJBException: No EJBContainer provider available: no provider names had been found."
What is the reason for this error?

pom.xml

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.glassfish.main.extras</groupId>
            <artifactId>glassfish-embedded-all</artifactId>
            <version>6.2.0</version>
            <scope>test</scope>
        </dependency>
</dependencies>


Test class:

public class ItemServiceIT {

    private static Context ctx;
    private static EJBContainer ejbContainer;

    @BeforeClass
    public static void setUpClass() {
        Map<String, Object> properties = new HashMap<>();

        properties.put("org.glassfish.ejb.embedded.glassfish.instance.root",
                "./src/test/domain");
        ejbContainer = EJBContainer.createEJBContainer(properties);
        ctx = ejbContainer.getContext();
    }

    @AfterClass
    public static void closeConn() {
        if (ejbContainer != null) {
            ejbContainer.close();
        }
    }

    @Test
    public void itemPersistTest() {
        //
    }
}


I also copied the domain1/config folder to the test project.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question