Hot questions for Using GlassFish in integration testing

Top Java Programmings / GlassFish / integration testing

Question:

I am having trouble to get a simple Arquillian test run. The following error appears when I try to run Arquillian with the GlassFish remote container:

Jun 12, 2016 3:50:05 PM org.jboss.arquillian.container.impl.MapObject populate
WARNUNG: Configuration contain properties not supported by the backing object org.jboss.arquillian.container.glassfish.remote_3_1.GlassFishRestConfiguration
Unused property entries: {jbossHome=target/jboss-as-7.1.1.Final}
Supported property names: [adminHttps, remoteServerHttpPort, libraries, type, remoteServerAddress, target, remoteServerAdminPort, remoteServerAdminHttps, adminUser, authorisation, adminPort, properties, adminHost, adminPassword]

java.lang.NoSuchMethodError: org.jboss.arquillian.container.spi.client.deployment.Validate.isArchiveOfType(Ljava/lang/Class;Lorg/jboss/shrinkwrap/api/Archive;)Z

    at org.jboss.arquillian.protocol.servlet.v_3.ServletProtocolDeploymentPackager.generateDeployment(ServletProtocolDeploymentPackager.java:64)
    at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.buildTestableDeployments(DeploymentGenerator.java:193)
    at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.createTestableDeployments(DeploymentGenerator.java:148)
    at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:85)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
    at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)
    at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
    at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
    at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)



Test ignored.
Process finished with exit code 255

This is the test:

import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;

import de.unisaarland.discanno.rest.services.v1.UserFacadeREST;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class UserFacadeRESTTest {

    @Deployment(testable=true)
    public static JavaArchive createDeployment() {
        JavaArchive jar =
                ShrinkWrap.create(JavaArchive.class)
                    .addClasses(UserFacadeREST.class,
                            Service.class,
                            ProjectDAO.class,
                            UsersDAO.class)
                    .addAsResource("META-INF/persistence.xml")
                    .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

        return jar;
    }

    @Test
    @InSequence(0)
    public void should_create_greeting() {

    }

}

I also tried it with WebArchive instead of JavaArchive, but the error remains the same. I also tried the solution provided by "tommsdk": Cannot run Arquillian test case on Glassfish but it won't resolve the dependency "import org.jboss.shrinkwrap.resolver.api.maven.Maven;".

This is the pom.xml for the glassfish remote setting:

https://gist.github.com/JeannedArk/55769ada7a632ff03f8db1b82823a0ce

Unfortunately it is quite a big project therefore the pom is quite big as well. This is the error message when I try to run the test with the wildfly managed configuration:

Test ignored.Jun 12, 2016 4:04:36 PM org.jboss.as.arquillian.container.managed.ManagedDeployableContainer startInternal

INFORMATION: Starting container with: [/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/bin/java, -Xmx512m, -XX:MaxPermSize=256m, -ea, -Djboss.home.dir=target/wildfly-8.1.0.Final, -Dorg.jboss.boot.log.file=/Users/.../discanno/target/wildfly-8.1.0.Final/standalone/log/server.log, -Dlogging.configuration=file:/Users/.../discanno/target/wildfly-8.1.0.Final/standalone/configuration/logging.properties, -Djboss.bundles.dir=target/wildfly-8.1.0.Final/bundles, -jar, /Users/.../discanno/target/wildfly-8.1.0.Final/jboss-modules.jar, -mp, target/wildfly-8.1.0.Final/modules, org.jboss.as.standalone, -server-config, standalone.xml]

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Jun 12, 2016 4:04:37 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.2.Final
Jun 12, 2016 4:04:37 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.2.Final
Jun 12, 2016 4:04:37 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.3.Final

16:04:37,529 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
16:04:37,768 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
16:04:37,866 INFO  [org.jboss.as] (MSC service thread 1-6) JBAS015899: WildFly 8.1.0.Final "Kenny" starting
16:04:38,909 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
16:04:38,931 INFO  [org.xnio] (MSC service thread 1-13) XNIO version 3.2.2.Final
16:04:38,941 INFO  [org.xnio.nio] (MSC service thread 1-13) XNIO NIO Implementation Version 3.2.2.Final
16:04:38,966 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
[0;33m16:04:38,967 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
[0;0m16:04:38,968 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
16:04:38,978 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
16:04:38,979 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
[0;0m16:04:38,978 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
[0;0m16:04:38,979 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
16:04:38,984 INFO  [org.jboss.as.security] (MSC service thread 1-7) JBAS013170: Current PicketBox version=4.0.21.Beta1
16:04:39,015 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-9) JBAS017502: Undertow 1.0.15.Final starting
[0;0m16:04:39,015 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.0.15.Final starting
16:04:39,048 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.5.Final)
16:04:39,065 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
16:04:39,074 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) JBAS010417: Started Driver service with driver-name = h2
16:04:39,097 INFO  [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service
[0;0m16:04:39,098 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
16:04:39,107 INFO  [org.jboss.remoting] (MSC service thread 1-13) JBoss Remoting version 4.0.3.Final
16:04:39,199 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /Users/.../discanno/target/wildfly-8.1.0.Final/welcome-content
16:04:39,248 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017525: Started server default-server.
16:04:39,352 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017531: Host default-host starting
16:04:39,417 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017519: Undertow HTTP listener default listening on /127.0.0.1:8080
16:04:39,577 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory /Users/.../discanno/target/wildfly-8.1.0.Final/standalone/deployments
16:04:39,605 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
16:04:39,782 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.4.Final
16:04:39,820 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
[0;0m16:04:39,821 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
[0;0m16:04:39,822 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.1.0.Final "Kenny" started in 2692ms - Started 184 of 233 services (81 services are lazy, passive or on-demand)
java.lang.NoSuchMethodError: org.jboss.arquillian.container.spi.client.deployment.Validate.isArchiveOfType(Ljava/lang/Class;Lorg/jboss/shrinkwrap/api/Archive;)Z


  at org.jboss.arquillian.protocol.servlet.v_3.ServletProtocolDeploymentPackager.generateDeployment(ServletProtocolDeploymentPackager.java:64)
  at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.buildTestableDeployments(DeploymentGenerator.java:193)
  at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.createTestableDeployments(DeploymentGenerator.java:148)
  at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:85)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
  at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
  at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:100)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
  at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
  at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
  at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
  at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
  at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
  at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)
  at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
  at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
  at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)


16:04:44,069 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-11) JBAS010409: Unbound data source [java:jboss/datasources/ExampleDS]
[0;0m16:04:44,069 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-12) JBAS017532: Host default-host stopping
16:04:44,076 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) JBAS010418: Stopped Driver service with driver-name = h2
[0;0m16:04:44,078 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-16) JBAS017521: Undertow HTTP listener default suspending
[0;0m16:04:44,079 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-16) JBAS017520: Undertow HTTP listener default stopped, was bound to /127.0.0.1:8080
[0;0m16:04:44,081 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-12) JBAS017506: Undertow 1.0.15.Final stopping
Jun 12, 2016 4:04:44 PM org.jboss.remoting3.remote.RemoteConnection handleException
ERROR: JBREM000200: Remote connection failed: java.io.IOException: Connection reset by peer
16:04:44,090 INFO  [org.jboss.as] (MSC service thread 1-1) JBAS015950: WildFly 8.1.0.Final "Kenny" stopped in 22ms


Process finished with exit code 255

This is the corresponding pom.xml:

https://gist.github.com/JeannedArk/032fc600d1abddd9c7f8cf8fcd15a7ed

Additionally here is the mvn dependency tree output if that helps you:

https://gist.github.com/JeannedArk/5709d130ac0fcb65e8976b85bc5280f2

I really tried a lot of configurations and researched a lot but it didn't work. Meanwhile I do not care in which container the tests run. I would prefer GlassFish, because we use GlassFish as application server, but I ran also into a lot of issues with the embedded GlassFish container. Therefore it would be also okay if it works with the remote GlassFish oder managed Wildfly container. The body text is limited to 30.000 characters therefore some sources are linked to a Gist, because espescially the pom files are pretty big.

Update: This is the arquillian.xml:

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

    <!-- Sets the protocol which is how Arquillian talks and executes the tests inside the container -->
    <defaultProtocol type="Servlet 3.0" />
    <!-- <defaultProtocol type="jmx-as7" /> --> <!-- error msg stays the same when changing this parameter -->

    <container qualifier="widlfly-managed" default="true">
        <configuration>
            <property name="jbossHome">${jbossHome:target/wildfly-8.1.0.Final}</property>
        </configuration>
    </container>

</arquillian>

Answer:

It really took some time, but thanks to this thread Configure Manuel container IntelliJ Arquillian Wildfly I could solve the error. It only works for me with the currently newest version '1.1.11.Final' and not '1.0.3.Final'. Apparently the Arquillian team must have fixed this issue, because I can reproduce it with the older version and it works with the newer one!

The pom.xml of the working version looks like this:

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>1.1.11.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

Question:

I'm working on a project that makes use of Arquillian and Maven to perform integration tests against a remote Glassfish 4.1 container and a remote Wildfly 8.2 container. When the tests are running against the remote Wildfly container everything works fine, however when running against the remote Glassfish container the tests fail with a series of errors.

The Maven output reports an internal server error and also shows that the test failed due to a NullPointerException but I believe this is actually a result of the Shrinkwrap deployment not being deployed to the Glassfish container rather than an error in the code itself.

The Glassfish server log shows no sign of anything being deployed to the container but there is a TimeoutException recorded in the log file when the integration test is run.

What I don't understand is what I'm doing wrong that prevents the test running against a remote Glassfish 4.1 container. Given that the same test passes without any problems on a remote Wildfly 8.2 container, I believe the problem lies with the Arquillian configuration in my project rather than the code being tested.

Update: After some further investigation this appears to be a very specific problem with Glassfish 4.1 where secure admin (HTTPS) has been enabled. If I run the test on a Glassfish 4.1 container with secure admin disabled then the test succeeds. If I run the test on a Glassfish 4.0 container with secure admin enabled then the test also succeeds. Unfortunately Glassfish requires secure admin to be enabled to deploy to a container running on another host, so the only workaround I can see at the moment is to downgrade to Glassfish 4.0.

The relevant section of the arquillian.xml file is as follows:

<container qualifier="arquillian-glassfish-remote">
  <configuration>
    <property name="adminUser">xxxx</property>
    <property name="adminPassword">xxxx</property>
    <property name="adminHttps">true</property>
    <property name="adminHost">xxxx</property>
    <property name="adminPort">4848</property>
    <property name="target">server</property>
  </configuration>
  <protocol type="Servlet 3.0">
    <property name="host">xxxx</property>
    <property name="port">8080</property>
  </protocol>
</container>

The relevant section of the pom.xml file is as follows:

<dependencies>
  <!-- Java EE Dependencies -->
  <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
  </dependency>

  <!-- Internal Dependencies -->
  <dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>project-ejb</artifactId>
    <version>${project.version}</version>
  </dependency>

  <!-- Test Dependencies -->
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.jboss.arquillian.junit</groupId>
    <artifactId>arquillian-junit-container</artifactId>
    <scope>test</scope>
  </dependency>
</dependencies>

...

<profile>
  <id>arquillian-glassfish-remote</id>
  <dependencies>
    <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-glassfish-remote-3.1</artifactId>
      <version>1.0.0.CR4</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <encoding>UTF-8</encoding>
          <includes>
            <include>**/IT*.java</include>
            <include>**/*IT.java</include>
            <include>**/*ITCase.java</include>
          </includes>
          <systemPropertyVariables>
            <arquillian.launch>arquillian-glassfish-remote</arquillian.launch>
          </systemPropertyVariables>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

The relevant section of the parent pom.xml is as follows:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>1.1.8.Final</version>
      <scope>import</scope>
      <type>pom</type>
    </dependency>
  </dependencies>
</dependencyManagement>

The relevent section of the Maven output is as follows:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running myproject.test.whitebox.ejb.MyServiceIT
Jun 26, 2015 7:45:42 PM org.jboss.arquillian.container.glassfish.clientutils.GlassFishClientUtil getResponseMap
SEVERE:  [status: SERVER_ERROR reason: Internal Server Error]
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 101.582 sec <<< FAILURE! - in myproject.test.whitebox.ejb.MyServiceIT
myproject.test.whitebox.ejb.MyServiceIT  Time elapsed: 101.582 sec  <<< ERROR!
java.lang.NullPointerException: null
    at org.jboss.arquillian.container.glassfish.clientutils.GlassFishClientUtil.getResponseMap(GlassFishClientUtil.java:163)
    at org.jboss.arquillian.container.glassfish.clientutils.GlassFishClientUtil.POSTMultiPartRequest(GlassFishClientUtil.java:131)
    at org.jboss.arquillian.container.glassfish.clientutils.GlassFishClientService.doDeploy(GlassFishClientService.java:245)
    at org.jboss.arquillian.container.glassfish.CommonGlassFishManager.deploy(CommonGlassFishManager.java:101)
    at org.jboss.arquillian.container.glassfish.remote_3_1.GlassFishRestDeployableContainer.deploy(GlassFishRestDeployableContainer.java:71)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:161)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:128)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:271)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:127)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.container.impl.client.container.DeploymentExceptionHandler.verifyExpectedExceptionDuringDeploy(DeploymentExceptionHandler.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createDeploymentContext(ContainerDeploymentContextHandler.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:95)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:80)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachDeployment(ContainerDeployController.java:263)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachManagedDeployment(ContainerDeployController.java:239)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deployManaged(ContainerDeployController.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:101)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:87)
    at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:201)
    at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:422)
    at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
    at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:218)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:166)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)


Results :

Tests in error: 
  MyServiceIT.myproject.test.whitebox.ejb.MyServiceIT ยป NullPointer

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

The relevant section of the Glassfish server.log file is as follows:

[2015-06-26T19:52:25.713+0100] [glassfish 4.1] [INFO] [NCLS-REST-00003] [javax.enterprise.admin.rest] [tid: _ThreadID=225 _ThreadName=admin-listener(18)] [timeMillis: 1435344745713] [levelValue: 800] [[
  An error occurred while processing the request. Please see the server logs for details.
org.glassfish.jersey.server.ContainerException: java.io.IOException: java.util.concurrent.TimeoutException
        at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer$ResponseWriter.rethrow(GrizzlyHttpContainer.java:317)
        at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer$ResponseWriter.failure(GrizzlyHttpContainer.java:299)
        at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:439)
        at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028)
        at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:365)
        at org.glassfish.admin.rest.adapter.RestAdapter$2.service(RestAdapter.java:316)
        at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: java.util.concurrent.TimeoutException
        at org.glassfish.grizzly.nio.transport.TCPNIOTransportFilter.handleRead(TCPNIOTransportFilter.java:90)
        at org.glassfish.grizzly.filterchain.TransportFilter.handleRead(TransportFilter.java:173)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.read(DefaultFilterChain.java:351)
        at org.glassfish.grizzly.filterchain.FilterChainContext.read(FilterChainContext.java:695)
        at org.glassfish.grizzly.portunif.BackChannelFilter.handleRead(BackChannelFilter.java:80)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.read(DefaultFilterChain.java:351)
        at org.glassfish.grizzly.filterchain.FilterChainContext.read(FilterChainContext.java:695)
        at org.glassfish.grizzly.portunif.BackChannelFilter.handleRead(BackChannelFilter.java:80)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.read(DefaultFilterChain.java:351)
        at org.glassfish.grizzly.filterchain.FilterChainContext.read(FilterChainContext.java:695)
        at org.glassfish.grizzly.http.io.InputBuffer.blockingRead(InputBuffer.java:1119)
        at org.glassfish.grizzly.http.server.io.ServerInputBuffer.blockingRead(ServerInputBuffer.java:95)
        at org.glassfish.grizzly.http.io.InputBuffer.fill(InputBuffer.java:1143)
        at org.glassfish.grizzly.http.io.InputBuffer.read(InputBuffer.java:353)
        at org.glassfish.grizzly.http.server.NIOInputStreamImpl.read(NIOInputStreamImpl.java:83)
        at org.glassfish.jersey.message.internal.EntityInputStream.read(EntityInputStream.java:101)
        at org.jvnet.mimepull.MIMEParser.fillBuf(MIMEParser.java:440)
        at org.jvnet.mimepull.MIMEParser.readBody(MIMEParser.java:216)
        at org.jvnet.mimepull.MIMEParser.access$600(MIMEParser.java:68)
        at org.jvnet.mimepull.MIMEParser$MIMEEventIterator.next(MIMEParser.java:165)
        at org.jvnet.mimepull.MIMEParser$MIMEEventIterator.next(MIMEParser.java:132)
        at org.jvnet.mimepull.MIMEMessage.makeProgress(MIMEMessage.java:198)
        at org.jvnet.mimepull.MIMEMessage.parseAll(MIMEMessage.java:181)
        at org.jvnet.mimepull.MIMEMessage.getAttachments(MIMEMessage.java:106)
        at org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide.readMultiPart(MultiPartReaderClientSide.java:225)
        at org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide.readMultiPart(MultiPartReaderServerSide.java:89)
        at org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide.readFrom(MultiPartReaderClientSide.java:179)
        at org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide.readFrom(MultiPartReaderClientSide.java:91)
        at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:251)
        at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:229)
        at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:149)
        at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:73)
        at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:149)
        at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1124)
        at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:851)
        at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:783)
        at org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:233)
        at org.glassfish.jersey.media.multipart.internal.FormDataParamValueFactoryProvider.getEntity(FormDataParamValueFactoryProvider.java:369)
        at org.glassfish.jersey.media.multipart.internal.FormDataParamValueFactoryProvider.access$000(FormDataParamValueFactoryProvider.java:86)
        at org.glassfish.jersey.media.multipart.internal.FormDataParamValueFactoryProvider$FormDataMultiPartValueFactory.provide(FormDataParamValueFactoryProvider.java:309)
        at org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:81)
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$AbstractMethodParamInvoker.getParamValues(JavaResourceMethodDispatcherProvider.java:121)
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:387)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:331)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:103)
        at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:271)
        ... 44 more
Caused by: java.util.concurrent.TimeoutException
        at org.glassfish.grizzly.nio.tmpselectors.TemporarySelectorReader.read(TemporarySelectorReader.java:126)
        at org.glassfish.grizzly.nio.tmpselectors.TemporarySelectorReader.read(TemporarySelectorReader.java:75)
        at org.glassfish.grizzly.AbstractReader.read(AbstractReader.java:72)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransportFilter.handleRead(TCPNIOTransportFilter.java:77)
        ... 100 more
]]

Answer:

After a lot of investigation I've found that this problem is caused by a bug in Grizzly version 2.3.15 which is bundled with Glassfish 4.1.

The issue is documented in https://java.net/jira/browse/GLASSFISH-21180 and https://java.net/jira/browse/GRIZZLY-1713.

I've tried copying a later version of the nucleus-grizzly-all.jar to the modules directory but Glassfish fails to start.

The best workaround around appears to be documented in TimeoutException on remote Glassfish v4.1 deployment which suggests downloading a patched version of nucleus-grizzly-all.jar from https://dl.dropboxusercontent.com/u/7319744/glassfish-4.1/nucleus-grizzly-all.jar.

Question:

I have the following real project structure:

EAR
 - lib/commons.jar
 - lib/another dependencies
 - ejb.jar

I want to test it with arquillian but I always get an exception.

This is my java method where the EAR is built:

@Deployment
public static Archive<?> createTestArchive() {
    //create ear
    EnterpriseArchive ear = ShrinkWrap
            .create(EnterpriseArchive.class, "test-app.ear");

    // create ejb-jar
    JavaArchive ejb = ShrinkWrap
            .create(JavaArchive.class, "test-ejb.jar")
            .addPackage("a.b.ejb")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

    // resolve ejb dependencies
    File[] dependencies = Maven.resolver()
            .loadPomFromFile("pom.xml")
            .importDependencies(ScopeType.COMPILE, ScopeType.TEST)
            .resolve()
            .withTransitivity()
            .asFile();

    ear.addAsModule(ejb);
    ear.addAsLibraries(dependencies);
    ear.setApplicationXML("glassfish-resources.xml");

    LOGGER.debug("content: " + ear.toString(true));
    return ear;
}

The content looks fine but something is not okay because I get this exception:

ArquillianServletRunner not found.
Could not determine ContextRoot from ProtocolMetadata, please contact DeployableContainer developer.

JAR content:

/a/
/a/b/
/a/b/ejb/
/a/b/ejb/MyEjb.class
...
/META-INF/
/META-INF/beans.xml

EAR content

/test-ejb.jar
/lib/
/lib/commons-444750341265461918.jar
/lib/slf4j-api-1.7.21.jar
/lib/slf4j-log4j12-1.7.21.jar
/lib/guava-21.0.jar
...
/lib/arquillian-testenricher-initialcontext-1.1.13.Final.jar
/lib/payara-embedded-all-4.1.1.171.0.1.jar
/lib/postgresql-42.0.0.jar
/META-INF/
/META-INF/application.xml

Answer:

The reason why I got "ArquillianServletRunner not found" error was because there was an error on EJB level.

The following test code works properly:

@RunWith(Arquillian.class)
public class EchoServiceBeanTest {

    @EJB
    private EchoService echoService;

    @Deployment
    public static Archive<?> createDeployment() {
        // create ear
        EnterpriseArchive ear = ShrinkWrap
                .create(EnterpriseArchive.class, "test-app.ear");

        // create ejb.jar
        JavaArchive ejb = ShrinkWrap
                .create(JavaArchive.class, "test-ejb.jar")
                .addPackages(true, "a.b.ejb")
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
        LOGGER.debug("EJB content: " + ejb.toString(true));

        // build ear
        ear.addAsModule(ejb);

        LOGGER.debug("EAR deployment content: " + ear.toString(true));
        return ear;
    }

    @Test
    public void echo() throws Exception {
        Assert.assertNotNull(echoService);
        String expected = "hello";
        String returned = echoService.echo(expected);
        Assert.assertEquals(expected, returned);
    }
}

used maven dependencies:

<dependencies>
    <!-- provided jars -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <!-- junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <!-- log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
    </dependency>
    <!-- arquillian -->
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <version>1.1.13.Final</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>
    <!-- embedded EE container -->
    <dependency>
        <groupId>fish.payara.extras</groupId>
        <artifactId>payara-embedded-all</artifactId>
        <version>4.1.1.171.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>