7 Replies Latest reply on Dec 5, 2010 9:22 AM by Aslak Knutsen

    Arquillian configuration with Glassfish v3 remote

    wamouk Newbie

      As in the arquillian documentation described I have created an eclipse project and configured maven to write tests for a j2ee project.

       

      In the test project:

      src/test/resources -> jndi.properties:

       

      java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory
      java.naming.factory.url.pkgs=com.sun.enterprise.naming
      java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
      org.omg.CORBA.ORBInitialHost=localhost
      org.omg.CORBA.ORBInitialPort=3700

       

       

      in root arquillian.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns="http://jboss.com/arquillian"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:glassfish="urn:arq:org.jboss.arquillian.container.glassfish.remote_3">

        <glassfish:container>
          <glassfish:remoteServerAddress>192.168.1.99</glassfish:remoteServerAddress>
          <glassfish:remoteServerHttpPort>8080</glassfish:remoteServerHttpPort>
          <glassfish:deploymentUri>deployer:Sun:AppServer::localhost:4848</glassfish:deploymentUri>
          <glassfish:deploymentUsername>user</glassfish:deploymentUsername>
          <glassfish:deploymentPassword>password</glassfish:deploymentPassword>
        </glassfish:container>

      </arquillian>

       

       

      included into the projects pom-file:

       

        <properties>
          <arquillian.version>1.0.0.Alpha4</arquillian.version>
        </properties>

       

          <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.ejb</artifactId>
            <version>3.1-b21</version>
            <scope>compile</scope>
          </dependency>

       

          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>compile</scope>
          </dependency>

       

          <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.0-SP1</version>
          </dependency>

       

          <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-junit</artifactId>
            <version>${arquillian.version}</version>
            <scope>test</scope>
          </dependency>

       

          <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-glassfish-remote-3</artifactId>
            <version>${arquillian.version}</version>
            <scope>test</scope>
          </dependency>

       

          <dependency>
            <groupId>org.glassfish.deployment</groupId>
            <artifactId>deployment-client</artifactId>
            <version>3.0.1-b19</version>
            <scope>test</scope>
          </dependency>

       

       

      I am executing the following test:

       

      @RunWith(Arquillian.class)

      public class Test_PatientDao_arquillian {

       

        @EJB

        private PatientDao patientDao;

       

        @Deployment

        public static JavaArchive createTestArchive() {

        return ShrinkWrap.create(JavaArchive.class, "test.jar")

                         .addClasses(Patient.class);

        }

       

        @Before

        public void setUp() {

          Test_Util.setProperties(this.properties);

          Test_Util.startImporterTest(this.properties);

        }

       

        @After

        public void shutDown() {

          Test_Util.cleanTables(this.properties);

        }

       

        @Test

        public void test_findPatient() {

            Patient patient = this.patientDao.findPatient();

       

            Assert.assertNotNull(patientDao);

            Assert.assertNotNull(patient);

        }

       

      }

       

       

      The problem is that I keep getting the following error message:

       

      org.jboss.arquillian.impl.event.FiredEventException: org.jboss.arquillian.spi.DeploymentException: Could not deploy archive
          at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:68)
          at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
          at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:96)
          at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:162)
          at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)
          at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
          at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)
          at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
          at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: org.jboss.arquillian.spi.DeploymentException: Could not deploy archive
          at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.deploy(JSR88RemoteContainer.java:146)
          at org.jboss.arquillian.container.glassfish.remote_3.GlassFishJSR88RemoteContainer.deploy(GlassFishJSR88RemoteContainer.java:63)
          at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:62)
          at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:50)
          at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
          ... 14 more
      Caused by: java.lang.IllegalStateException: error submitting remote command
          at org.glassfish.deployapi.SunDeploymentManager.getTargets(SunDeploymentManager.java:166)
          at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.deploy(JSR88RemoteContainer.java:135)
          ... 18 more
      Caused by: java.lang.RuntimeException: error submitting remote command
          at org.glassfish.deployment.client.AbstractDeploymentFacility.listTargets(AbstractDeploymentFacility.java:637)
          at org.glassfish.deployapi.SunDeploymentManager.getTargets(SunDeploymentManager.java:164)
          ... 19 more
      Caused by: java.lang.RuntimeException: com.sun.enterprise.admin.cli.AuthenticationException: Authentication failed for user: admin
      (Usually, this means invalid user name and/or password)
          at org.glassfish.deployment.client.RemoteDeploymentFacility$RemoteCommandRunner.run(RemoteDeploymentFacility.java:117)
          at org.glassfish.deployment.client.AbstractDeploymentFacility.listTargets(AbstractDeploymentFacility.java:604)
          ... 20 more
      Caused by: com.sun.enterprise.admin.cli.AuthenticationException: Authentication failed for user: admin
      (Usually, this means invalid user name and/or password)
          at com.sun.enterprise.admin.cli.remote.RemoteCommand.doHttpCommand(RemoteCommand.java:558)
          at com.sun.enterprise.admin.cli.remote.RemoteCommand.fetchCommandMetadata(RemoteCommand.java:790)
          at com.sun.enterprise.admin.cli.remote.RemoteCommand.prepare(RemoteCommand.java:209)
          at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:244)
          at org.glassfish.deployment.client.RemoteDeploymentFacility$RemoteCommandRunner.run(RemoteDeploymentFacility.java:113)
          ... 21 more

       

       

      Any help would be appreciated!

        • 1. Re: Arquillian configuration with Glassfish v3 remote
          Aslak Knutsen Master

          If this is a default installed GlassFish, you can just remove the password field from arquillian.xml and you should be good to go.

           

          ps: You shouldn't need the jndi.properties for GlassFish Remote

          • 2. Re: Arquillian configuration with Glassfish v3 remote
            wamouk Newbie

            Thanks for the fast reply. The problem was that arquillian.xml was at a wrong location. Instead of the root I moved it into the folder src/test/resources. Now I am one step further.

             

            At the moment I keep getting the following error message:

            ...

            Caused by: javax.naming.NamingException: No EJB found in JNDI, tried the following names: java:global/test.ear/test/PatientDaoBean, java:global/test.ear/test/PatientDao, java:global/test/PatientDao

            ...

             

            I don´t understand the JNDI lookup, it should be something like:

            java:global/test/...dao.PatientDao

             

            Where does the test.ear file come from? As you can see I defined test.jar as deployment file:

            @Deployment

              public static JavaArchive createTestArchive() {

              return ShrinkWrap.create(JavaArchive.class, "test.jar")

                               .addClasses(Patient.class);

              }

             

            test.jar contains every class that is needed and is deployed in the application folder of glassfish. The problem is that it is not unpacked.

            Maybe you have the solution!?

            • 4. Re: Arquillian configuration with Glassfish v3 remote
              wamouk Newbie

              Thanks for the links, I added a line to the archive-creation:

               

              @Deployment

                public static JavaArchive createTestArchive() {

                return ShrinkWrap.create(JavaArchive.class, "test.jar")

                                 .addClasses(Patient.class),

                                 .addManifestResource(EmptyAsset.INSTANCE, "beans.xml");

                }

               

               

              No I get the following error message:

               

              org.jboss.arquillian.impl.event.FiredEventException: org.jboss.arquillian.spi.DeploymentException: Could not deploy archive
                  at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:68)
                  at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
                  at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:96)
                  at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:162)
                  at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)
                  at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                  at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)
                  at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                  at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
                  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
                  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
              Caused by: org.jboss.arquillian.spi.DeploymentException: Could not deploy archive
                  at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.deploy(JSR88RemoteContainer.java:146)
                  at org.jboss.arquillian.container.glassfish.remote_3.GlassFishJSR88RemoteContainer.deploy(GlassFishJSR88RemoteContainer.java:63)
                  at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:62)
                  at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:50)
                  at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
                  ... 14 more
              Caused by: java.lang.RuntimeException: Module startup was interrupted or timed out
                  at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.waitForModuleToStart(JSR88RemoteContainer.java:292)
                  at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.deploy(JSR88RemoteContainer.java:139)
                  ... 18 more
              Caused by: java.util.concurrent.TimeoutException
                  at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:222)
                  at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:399)
                  at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.waitForModuleToStart(JSR88RemoteContainer.java:288)
                  ... 19 more

               

              Do you have any idea what this can mean?

              And again I am wondering why the test-archive "test.jar" is not unpacked with all its included classes.

              • 5. Re: Arquillian configuration with Glassfish v3 remote
                Aslak Knutsen Master

                Seems like it's taking to long to deploy, so it times out. Are your server running properly ?

                 

                Not sure what you mean by "is not unpacked" ?

                • 6. Re: Arquillian configuration with Glassfish v3 remote
                  wamouk Newbie

                  I altered the code a bit:

                   

                  final JavaArchive myEjbJar = ShrinkWrap.create(JavaArchive.class, "test.jar")
                                     .addPackage(IMomoThrowable.class.getPackage())
                                     .addPackage(MomoKisDbReadException.class.getPackage())
                                     .addPackage(Projection.class.getPackage())
                                     .addPackage(HibernateException.class.getPackage())
                                     .addPackage(Patient.class.getPackage())
                                     .addPackage(Logger.class.getPackage())
                                     .addPackage(AppenderAttachable.class.getPackage())
                                     .addPackage(LoggerHelper.class.getPackage())
                                     .addPackage(FileWatchdog.class.getPackage())
                                     .addPackage(RendererMap.class.getPackage())
                                     .addPackage(PropertySetter.class.getPackage())
                                     .addPackage(GlobalDao.class.getPackage())
                                     .addClass(PatientDao.class)
                                     .addManifestResource(EmptyAsset.INSTANCE, "beans.xml");

                   

                  But the exception is still coming. The JNDI-lookup works fine:

                  IPatientDAOFacade patientDao = (IPatientDAOFacade) initalcontext.lookup("java:global/.../PatientDaoFacade");

                   

                  GlassFish is running properly.

                   

                  The exception:

                  org.jboss.arquillian.impl.event.FiredEventException: org.jboss.arquillian.spi.DeploymentException: Could not deploy archive
                      at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:68)
                      at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
                      at org.jboss.arquillian.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:96)
                      at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:162)
                      at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)
                      at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                      at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)
                      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                      at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
                      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
                      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
                  Caused by: org.jboss.arquillian.spi.DeploymentException: Could not deploy archive
                      at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.deploy(JSR88RemoteContainer.java:146)
                      at org.jboss.arquillian.container.glassfish.remote_3.GlassFishJSR88RemoteContainer.deploy(GlassFishJSR88RemoteContainer.java:63)
                      at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:62)
                      at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(ContainerDeployer.java:50)
                      at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
                      ... 14 more
                  Caused by: java.lang.IllegalStateException: error submitting remote command
                      at org.glassfish.deployapi.SunDeploymentManager.getTargets(SunDeploymentManager.java:166)
                      at org.jboss.arquillian.container.jsr88.remote_1_2.JSR88RemoteContainer.deploy(JSR88RemoteContainer.java:135)
                      ... 18 more
                  Caused by: java.lang.RuntimeException: error submitting remote command
                      at org.glassfish.deployment.client.AbstractDeploymentFacility.listTargets(AbstractDeploymentFacility.java:637)
                      at org.glassfish.deployapi.SunDeploymentManager.getTargets(SunDeploymentManager.java:164)
                      ... 19 more
                  Caused by: java.lang.RuntimeException: com.sun.enterprise.admin.cli.CommandException: Remote server does not listen for requests on [192.168.1.99:4848].
                  Is the server up?
                      at org.glassfish.deployment.client.RemoteDeploymentFacility$RemoteCommandRunner.run(RemoteDeploymentFacility.java:117)
                      at org.glassfish.deployment.client.AbstractDeploymentFacility.listTargets(AbstractDeploymentFacility.java:604)
                      ... 20 more
                  Caused by: com.sun.enterprise.admin.cli.CommandException: Remote server does not listen for requests on [192.168.1.99:4848].
                  Is the server up?
                      at com.sun.enterprise.admin.cli.remote.RemoteCommand.doHttpCommand(RemoteCommand.java:486)
                      at com.sun.enterprise.admin.cli.remote.RemoteCommand.fetchCommandMetadata(RemoteCommand.java:790)
                      at com.sun.enterprise.admin.cli.remote.RemoteCommand.prepare(RemoteCommand.java:209)
                      at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:244)
                      at org.glassfish.deployment.client.RemoteDeploymentFacility$RemoteCommandRunner.run(RemoteDeploymentFacility.java:113)
                      ... 21 more
                  Caused by: java.net.ConnectException: Connection refused: connect
                      at java.net.PlainSocketImpl.socketConnect(Native Method)
                      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
                      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
                      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
                      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
                      at java.net.Socket.connect(Socket.java:529)
                      at java.net.Socket.connect(Socket.java:478)
                      at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
                      at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
                      at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
                      at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
                      at sun.net.www.http.HttpClient.New(HttpClient.java:306)
                      at sun.net.www.http.HttpClient.New(HttpClient.java:323)
                      at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:975)
                      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:916)
                      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)
                      at com.sun.enterprise.admin.cli.remote.RemoteCommand$2.doCommand(RemoteCommand.java:796)
                      at com.sun.enterprise.admin.cli.remote.RemoteCommand.doHttpCommand(RemoteCommand.java:477)
                      ... 25 more

                   

                  What could be the reason? I fear it will be a small thing I forgot.

                  • 7. Re: Arquillian configuration with Glassfish v3 remote
                    Aslak Knutsen Master

                    Well, the basic error is:

                     

                    Remote server does not listen for requests on [192.168.1.99:4848].

                    Connection refused: connect

                     

                    Are yoyu sure the server is running, on that ip/port? Any firewalls between you and the server?