6 Replies Latest reply on Sep 3, 2012 4:27 AM by sharadac85

    running arquillian test on domain remote

    sharadac85

      Hi,

       

      I am new to arquillian. Using a few tips on the community I have written a test and I wish to run this on a remote domain setup. My arquillian.xml looks as below:

       

      <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">

          <engine>

              <property name="deploymentExportPath">target</property>

          </engine>

          <container qualifier="jbossas7">

              <configuration>

                  <property name="managementAddress">a.b.c.d</property>

                  <property name="managementPort">29999</property>

                  <property name="username">aaa</property>

                  <property name="password">bbb</property>            

              </configuration>

          </container>

      </arquillian>

       

      I am using the following profile in my pom:

       

      <profile>

                  <id>arquillian-jbossas-managed</id>

                  <activation>

                      <activeByDefault>true</activeByDefault>

                  </activation>

                      <dependencies>

                          <dependency>

                              <groupId>org.jboss.spec</groupId>

                              <artifactId>jboss-javaee-6.0</artifactId>

                              <version>1.0.0.Final</version>

                              <type>pom</type>

                              <scope>provided</scope>

                          </dependency>

                          <dependency>

                              <groupId>org.jboss.as</groupId>

                              <artifactId>jboss-as-arquillian-container-domain-remote</artifactId>

                              <version>7.1.2.Final</version>

                              <scope>test</scope>

                          </dependency>

                            <dependency>

                              <groupId>org.jboss.arquillian.protocol</groupId>

                              <artifactId>arquillian-protocol-servlet</artifactId>

                              <scope>test</scope>

                          </dependency>

                      </dependencies>

                      <build>

                      <plugins>

                          <plugin>

                              <artifactId>maven-surefire-plugin</artifactId>

                              <configuration>

                                  <systemPropertyVariables>

                                      <JBOSS_HOST>a.b.c.d</JBOSS_HOST>

                                      <username>aaa</username>

                                      <password>bbb</password>

                                      <arquillian.launch>jbossas7</arquillian.launch>

                                  </systemPropertyVariables>                           

                              </configuration>

                          </plugin>

                      </plugins>

                  </build>

              </profile>

       

      When I run my test, I see the following stack trace in my surefire report:

       

      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.581 sec <<< FAILURE!

      org.arquillian.example.arquillian_tutorial.AppTest  Time elapsed: 8.575 sec  <<< ERROR!

      java.lang.UnsupportedOperationException: Can not deploy directly from a Domain Controller

          at org.jboss.as.arquillian.container.domain.CommonDomainDeployableContainer.deploy(CommonDomainDeployableContainer.java:180)

          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:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          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:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          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:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          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:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

       

      Please advice.

       

      Thanks,

      Sharada

        • 1. Re: running arquillian test on domain remote
          aslak

          The DomainController is not a deployment target. You will have to specify which server instance or server group you want to deploy to via @Deployment @TargetsContainer("name")

           

           

          https://github.com/jbossas/jboss-as/commit/47fa68f11029d35e827c65e4a09306664df56f1e

          • 2. Re: running arquillian test on domain remote
            sharadac85

            Thanks for your response Aslak.

             

            I forgot to add the test code snippet here.

             

            @RunWith(Arquillian.class)

            public class AppTest

            {

                static {

                    Security.addProvider(new JBossSaslProvider());

                }

                static JavaArchive jar;

             

                @Deployment(name="other-server-group")

                @TargetsContainer("jbossas7") //Container qualifier used in arquillian.xml

                public static JavaArchive createDeployment() {

                    jar = ShrinkWrap.create(JavaArchive.class)

                        .addClasses(CounterBean.class,RemoteCounter.class)

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

                    System.out.println(jar.toString(true));

                    return jar;

                }

             

                @Inject

                RemoteCounter counter;

             

                @Test

                @OperateOnDeployment("other-server-group")

                public void should_execute_stateful() throws Exception{

                    // Invoke a stateful bean

                    invokeStatefulBean();

                }

             

                /**

                 * Looks up a stateful bean and invokes on it

                 *

                 * @throws NamingException

                 */

                private static void invokeStatefulBean() throws NamingException {

                    // Let's lookup the remote stateful counter

                    final RemoteCounter statefulRemoteCounter = lookupRemoteStatefulCounter();

                    System.out.println("Obtained a remote stateful counter for invocation");

                    // invoke on the remote counter bean

                    final int NUM_TIMES = 5;

                    System.out.println("Counter will now be incremented " + NUM_TIMES + " times");

                    for (int i = 0; i < NUM_TIMES; i++) {

                        System.out.println("Incrementing counter");

                        statefulRemoteCounter.increment();

                        System.out.println("Count after increment is " + statefulRemoteCounter.getCount());

                    }

                    Scanner user_input = new Scanner( System.in );

                    String yes_no;

                    System.out.print("Enter Y/N: ");

                    yes_no = user_input.next( );

                    if(yes_no.equals("Y")||yes_no.equals("y")){

                        // now decrementing

                        System.out.println("Counter will now be decremented " + NUM_TIMES + " times");

                        for (int i = NUM_TIMES; i > 0; i--) {

                            System.out.println("Decrementing counter");

                            statefulRemoteCounter.decrement();

                            System.out.println("Count after decrement is " + statefulRemoteCounter.getCount());

                        }           

                    }

                    else{

                        System.out.print("Exiting");

                    }

                }

             

                /**

                 * Looks up and returns the proxy to remote stateful counter bean

                 *

                 * @return

                 * @throws NamingException

                 */

                private static RemoteCounter lookupRemoteStatefulCounter() throws NamingException {

                    final Hashtable jndiProperties = new Hashtable();

                    jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                    final Context context = new InitialContext(jndiProperties);

             

                  return (RemoteCounter) context.lookup(

                     "ejb:/"+jar+"/CounterBean!" + RemoteCounter.class.getName()+"?stateful"

                  );

                }

             

            }

             

            RemoteCounter is a view for the stateful session bean which has a few increment and decrement methods.

             

            Please advice.

             

            Regards,

            Sharada

            • 3. Re: running arquillian test on domain remote
              aslak

              The @Deployment.name is a reference to use with @OperatesOnDeployment to match a @Test methods to a specific deployment.

               

              @TargetsContainer is used to match which container this should be deployed, in your case, "other-server-group"

               

              The @TargetsContainer is normally used in combination with a <group> setup in arquillian.xml, where you refere to the specific <contianer qualifiers> in the group. The DomainController is a 'group' in itself, even when defined as a single <container>. The DomainControllers server-instances(server-one, server-two...) and server-groups(main-server-group, other-server-group) will be available as if they were manually defined in arquillian.xml as part of a <group>.

              1 of 1 people found this helpful
              • 4. Re: running arquillian test on domain remote
                sharadac85

                Hi Aslak,

                 

                Now, I am running into a new error on my host controller(which is also my domain controller):

                 

                DEBUG [org.jboss.as.protocol] (management-handler-thread - 4)  failed to process async request for org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler$1@65a7c4 on channel Channel ID 131862d6 (inbound) of Remoting connection 01e951c9 to null: org.jboss.remoting3.NotOpenException: Writes closed

                 

                Please help!

                 

                Thanks,

                Sharada

                • 5. Re: running arquillian test on domain remote
                  aslak

                  Is this from the server.log ? is  there any more info?

                  • 6. Re: running arquillian test on domain remote
                    sharadac85

                    This is not server.log...this is thrown on hostcontroller log file and can be seen if DEBUG logging level is turned on. I can see that I have to use Remoting dependency here, but not sure of the remoting jar that is required. Jboss As version is 7.1.2.Final. Please help me identify the dependency.

                     

                    Thanks,

                    Sharada