0 Replies Latest reply on Mar 21, 2013 7:47 AM by Manish Prajapati

    java.lang.IllegalStateException: Error launching test at http://127.0.0.1:8080/test/ArquillianServletRunner?outputMode=serializedObject&...

    Manish Prajapati Newbie

      I have an arqillian test and while executing, it executes the test properly but at the end I am getting below error :

       

      java.lang.IllegalStateException: Error launching test at http://127.0.0.1:8080/test/ArquillianServletRunner?outputMode=serializedObject&className=com.myapp.cli.MyAppSetup&methodName=run&cmd=event. Got 400 (Bad Request)

          at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.execute(ServletMethodExecutor.java:237)

          at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.access$000(ServletMethodExecutor.java:43)

          at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor$1.run(ServletMethodExecutor.java:99)

          at java.util.TimerThread.mainLoop(Timer.java:555)

          at java.util.TimerThread.run(Timer.java:505)

       

      My sample Arquillian test is as given below :

       

      package com.myapp.cli;

       

      import java.net.URL;

      import java.util.Enumeration;

      import java.util.Properties;

       

      import javax.inject.Inject;

      import javax.persistence.EntityManager;

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.Archive;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.asset.EmptyAsset;

      import org.jboss.shrinkwrap.api.spec.WebArchive;

      import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;

      import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

      import org.junit.Test;

      import org.junit.runner.RunWith;

       

      import com.myapp.cli.commands.BasicClientCreator;

      import com.myapp.cli.commands.InternalUserCreator;

      import com.myapp.seam.common.Constants;

      import com.myapp.seam.config.GeneralConfig;

      import com.myapp.seam.util.BeanManagerUtil;

       

       

      /**

      * MyappBasicSetup does only 1 thing which is to run the BasicClientCreator

      * for various clients.

      *

      *

      */

      @RunWith(Arquillian.class)

      public class MyappBasicSetup {

       

          @Inject

          static EntityManager em;

          //@Inject static BasicClientCreator basicCreator;

       

          @Deployment

          public static Archive<?> createTestArchive() {

              final MavenDependencyResolver resolver =

                      DependencyResolvers.use(MavenDependencyResolver.class)

                      .loadMetadataFromPom("pom.xml")

                      .includeDependenciesFromPom("pom.xml");

       

              return ShrinkWrap.create(WebArchive.class, "test.war")

                      .addPackages(true,"com.myapp.cli")

                      .addAsLibraries(resolver.resolveAsFiles())

                      .addAsResource("META-INF/myapp.rsa.pub", "META-INF/myapp.rsa.pub")

                      .addAsResource("META-INF/myapp.rsa.sec", "META-INF/myapp.rsa.sec")

                      .addAsResource("setup.properties", "setup.properties")

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

         }

       

          @Test

          public void run() throws Exception {

              main(new String[] {});

          }

          public static void main(String[] args) throws Exception {

              ClassLoader cl = Thread.currentThread().getContextClassLoader();

              Enumeration<URL> pubkeyfiles = cl.getResources("META-INF/myapp.rsa.pub");

              Enumeration<URL> seckeyfiles = cl.getResources("META-INF/myapp.rsa.sec");

       

              if (pubkeyfiles == null || !pubkeyfiles.hasMoreElements())

                  throw new RuntimeException("No public key found under META-INF/myapp.rsa.pub - Run keygen and copy myapp.rsa.pub and myapp.rsa.sec to classes/META-INF");

              if (seckeyfiles == null || !seckeyfiles.hasMoreElements())

                  throw new RuntimeException("No private key found under META-INF/myapp.rsa.sec - Run keygen and copy myapp.rsa.pub and myapp.rsa.sec to classes/META-INF");

              System.out.println("Found private and public key files");

       

              Properties prop = new Properties();

              prop.load(cl.getResourceAsStream("setup.properties"));

       

              //start here

              System.setProperty(Constants.Myapp_MODE, Constants.Myapp_MODE_SETUP);

              MyappBasicSetup basicSetup;

              basicSetup = new MyappBasicSetup();

              try {

                  basicSetup.setup();

                  //Lifecycle.beginCall();

       

                  // we need to get the system_environment from database.  In order to do

                  // that we need to have seam to use asyncEntityManager which doesn't depend on client.

                  BeanManagerUtil.getRequestContext().set("entityManager", em);

                  String sysEnv = GeneralConfig.instance().SYSTEM_ENVIRONMENT();

                  if (sysEnv.equals(GeneralConfig.SYS_ENV_PRODUCTION)) {

                      System.out.println("Running MyappBasicSetup() against production database!");

                  }

                  BeanManagerUtil.getRequestContext().set("entityManager", null);

       

                  // get the set of clients we will create from setup.properties file

                  String clientName = prop.getProperty("setup.clients");

       

                  System.out.println("Running basic client setup for " + clientName);

       

                  BasicClientCreator basicCreator=(BasicClientCreator )BeanManagerUtil.getInstance(BasicClientCreator.NAME);

                  basicCreator.setClientName(clientName);

                  basicCreator.setProperties(prop);

                  basicCreator.run();

       

                  InternalUserCreator internalUserCreator = BeanManagerUtil.getInstance(InternalUserCreator.class);

                  internalUserCreator.setProperties(prop);

                  internalUserCreator.run();

              } catch (Exception e) {

                  e.printStackTrace();

                  System.exit(1);

              } finally {

                  //Lifecycle.endCall();

                  basicSetup.teardown();

              }

              System.exit(0);

          }

       

          public void setup() throws Exception {

              System.out.println("Setting up");

              //super.startSeam();

          }

       

          public void teardown() throws Exception {

              System.out.println("Tearing down");

              //super.stopSeam();

          }

      }

       

      any idea? Help will be appreciated.

       

      Thanks,

      Manish