7 Replies Latest reply on Nov 23, 2011 3:59 AM by zpaulovics

    glassfish-remote and contextRoot

    mleduque

      Hi,

       

      I'm trying to run a test on a remote glassfish.

      Here is my arquillian.xml :

       

      {code:xml}<?xml version="1.0"?>

      <arquillian xmlns="http://jboss.com/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">

       

          <container qualifier="glassfish-embedded">

              <configuration>

                  <property name="configurationXml">src/test/resources/glassfish-embedded/domain.xml</property>

                  <property name="instanceRoot">target/root</property>

                  <property name="bindHttpPort">9090</property>

                  <property name="autoDelete">false</property>

              </configuration>

          </container>

          <container qualifier="remote-gf1" default="true" >

              <configuration>

                  <property name="contextRoot">_arq_out</property>

              </configuration>

              <protocol type="Servlet 3.0">

                  <property name="contextRoot">_arq_out</property>

              </protocol>

          </container>

      </arquillian>{code}

       

      {quote}When I run it, it fails with

      java.lang.IllegalArgumentException: contextRoot must not be null

          at org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet.<init>(Servlet.java:48)

          at org.jboss.arquillian.container.glassfish.remote_3_1.clientutils.GlassFishClientService.resolveWebModuleSubComponents(GlassFishClientService.java:340)

          at org.jboss.arquillian.container.glassfish.remote_3_1.clientutils.GlassFishClientService.doDeploy(GlassFishClientService.java:230)

          at org.jboss.arquillian.container.glassfish.remote_3_1.GlassFishRestDeployableContainer.deploy(GlassFishRestDeployableContainer.java:123){quote}

       

      As you can see in the arquillian.xml, I've tried many ways to give it a contextRoot, but I was unsuccessful. And I didn't find examples or documentation about it.

       

      Tell me : what am I doing wrong ?

        • 1. Re: glassfish-remote and contextRoot
          mleduque

          The stranger is that the EAR actually deployed in the server.

          Still, for arquillian, the deploy failed.

          • 2. Re: glassfish-remote and contextRoot
            zpaulovics

            Hi,

             

            You can set the context root by the name of your deployment or in your glassfish-web.xml file.

            • If you do not have sun-web.xml or glassfish-web.xml file in your web application, the GlassFish will use the name of your deployment without the extension as contextroot.
            • For how to define the context root in sun-web.xml or glassfish-web.xml file, please refer to GlassFish Server Open Source Edition 3.1 Application Deployment Guide -› The glassfish-web.xml File (page 89).

             

            For more details related to GlassFish 3.1 remote container, you can found the documentation here: https://docs.jboss.org/author/display/ARQ/GlassFish+3.1+-+Remote

             

            You can find an example of ear web application test here: git://github.com/arquillian/arquillian-container-glassfish.git in the file: /src/test/java/org/jboss/arquillian/container/glassfish/remote_3_1/GlassFishRestDeployEarTest.java

             

            {code}

                 public static Archive<?> getTestArchive() {

                    final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")

                            .addClasses(GreeterServlet.class);

                    final JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "test.jar")

                            .addClasses(Greeter.class);

                    final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")

                            .setApplicationXML("application.xml")

                            .addAsModule(war)

                            .addAsModule(ejb);

                    log.info(ear.toString(true));

                    return ear;

                }

            {code}

             

            Regards,

             

            ZoPa

            1 of 1 people found this helpful
            • 3. Re: glassfish-remote and contextRoot
              mleduque

              OK, that's a already good thing to know the doc is not exact, thanks.

               

              I'll try that, but that feels really strange to put a *-web.xml as I don't have a web part (i.e. no war, no webservices, no servlets...).

              • 4. Re: glassfish-remote and contextRoot
                mleduque

                Hmm, I have to put a

                {code}<glassfish-application>

                    <web>

                        <web-uri>???</web-uri>

                        <context-root>context</context-root>

                    </web>

                </glassfish-application>{code}

                 

                in the EAR *but* I'm still stuck by the fact that  I have *no* web component inside, so it's a bit problematic to find how I  should fill the fields...

                • 5. Re: glassfish-remote and contextRoot
                  zpaulovics

                  Hi Mickaël,

                   

                  You have faced with the ARQ-658 issue. It has been fixed in the master already. The contextroot is automatically specified by the container for you, so there is no need to put the application.xml into the archive. If one do not have any web componet (as it is your case now), the application.xml can not be included. 

                   

                  This is my test deployment:

                   

                  {code}

                  public class GlassFishRestDeployEarTest {

                      @Deployment

                          final JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "test.jar")

                                  .addClasses(Greeter.class, GlassFishRestDeployEarTest.class);

                          log.info(ejb.toString(true));

                          final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")

                                  .addAsModule(ejb);

                          log.info(ear.toString(true));

                          return ear;

                      }

                  ...

                  {code}

                   

                   

                  And this is my test log:

                   

                  {code}

                  -------------------------------------------------------

                  T E S T S

                  -------------------------------------------------------

                  Running org.jboss.arquillian.container.glassfish.remote_3_1.GlassFishRestDeployEarTest

                  Nov 22, 2011 4:10:55 PM org.jboss.arquillian.container.glassfish.remote_3_1.GlassFishRestDeployEarTest getTestArchive

                  INFO: test.jar:

                  /org/

                  /org/jboss/

                  /org/jboss/arquillian/

                  /org/jboss/arquillian/container/

                  /org/jboss/arquillian/container/glassfish/

                  /org/jboss/arquillian/container/glassfish/remote_3_1/

                  /org/jboss/arquillian/container/glassfish/remote_3_1/GlassFishRestDeployEarTest.class

                  /org/jboss/arquillian/container/glassfish/remote_3_1/Greeter.class

                  Nov 22, 2011 4:10:55 PM org.jboss.arquillian.container.glassfish.remote_3_1.GlassFishRestDeployEarTest getTestArchive

                  INFO: test.ear:

                  /test.jar

                  Nov 22, 2011 4:10:56 PM org.jboss.arquillian.container.glassfish.remote_3_1.clientutils.GlassFishClientService resolveWebModuleContextRoot

                  INFO: contextRoot: test

                  Nov 22, 2011 4:10:56 PM org.jboss.arquillian.container.glassfish.remote_3_1.clientutils.GlassFishClientService doDeploy

                  INFO: HTTPContext [host=localhost, port=8080, servlets=

                  Servlet [name=default, contextRoot=/test]

                  Servlet [name=ArquillianServletRunner, contextRoot=/test]

                  Servlet [name=jsp, contextRoot=/test]]

                  Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.615 sec

                  {code}

                   

                  Note: If your @Deployment does not have the "testable = false" parameter (it is not a client test), arquillion will append its servlets to your artifact  (like ArquillianServletRunner, etc.) as you can see in the above log.

                  • 6. Re: glassfish-remote and contextRoot
                    mleduque

                    OK, thanks, I understand now.

                    So as a workaround until the next release version, I just have to add a dummy war with a dummy servlet in the ear ?

                    • 7. Re: glassfish-remote and contextRoot
                      zpaulovics

                      Yes, your right, or you can use offline the attached arquillian-glassfish-remote-3.1-1.0.0.Final-SNAPSHOT.jar in your projects.