MaNa
MaNa

Reputation: 51

ManagedExecutorService not found

I have a problem with Arquillian and ManagedExecutorServices. Arquillian is not able to find the default ManagedExecutorService. The Exception is:

Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/DefaultManagedExecutorService

I am using IntelliJ and execute the test with GlassFish Embedded 3.1 with Arquillian 1.4.0.Final.

Here is my Unit Test:

@Slf4j
@RunWith(Arquillian.class)
public class WorkhorseTest {

    @Inject
    private Workhorse workhorse;

    @Deployment
    public static WebArchive createDeployment() {
        return ShrinkWrap.create(WebArchive.class)
                .addClass(Workhorse.class)
                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
    }

    @Test
    public void testExecution() throws Exception {
        final Future<Integer> result = workhorse.execute();
        result.get(1, TimeUnit.MINUTES);
        log.info("Executed...");
    }
}

Here is the EJB:

@Slf4j
@Singleton
public class Workhorse {

    @Resource
    private ManagedExecutorService mes;

    public Future<Integer> execute() {
        return mes.submit(() -> {
            log.info("Hello from a Runnable");
            return 5;
        });
    }


}

How can I test ManagedExecutorServices with Arquillian?

Upvotes: 1

Views: 712

Answers (1)

MaNa
MaNa

Reputation: 51

I solved it with switching a dependency in pom.xml:

Old:

<dependency>
    <groupId>org.glassfish.main.extras</groupId>
    <artifactId>glassfish-embedded-web</artifactId>
    <version>5.0</version>
    <scope>provided</scope>
</dependency>

New:

<dependency>
    <groupId>org.glassfish.main.extras</groupId>
    <artifactId>glassfish-embedded-all</artifactId>
    <version>5.0</version>
    <scope>provided</scope>
</dependency>

Upvotes: 1

Related Questions