3 Replies Latest reply on Nov 7, 2011 12:40 AM by Terence To

    Could not read active container configuration: null in Eclipse JUnit

    Terence To Newbie

      I created this Temperature Converter sample project in Eclipse.  My container is JBoss 6.0.  I was able to test the project in Maven command line successfully using

       

       

      mvn clean test -Pjbossas-remote-6 -Darquillian.launch=jbossas-remote-6

       

      However, I am getting the "Could not read container configuration: null" exception when I run the test in Eclipse JUnit.

      I have followed this page (https://docs.jboss.org/author/display/ARQ/Setting+up+and+running+the+test+in+Eclipse) to set the project's active

      maven profile to "jbossas-remote-6", but still no help.  Any suggestion or pointer is greatly appreciated.  I have been struggling with this for weeks and it is only the very first chapter of the EJB book. Many Thanks!

       

      I notices that this stack trace is the same as the exception thrown if I call "mvn clean test" without providing the "-Pjbossas-remote-6 -Darquillian.launch=jbossas-remote-6" option in maven cmd line.  Do I need to setup other paremters/options in Junit?

       

      java.lang.RuntimeException: Could not create and startup manager
      at org.jboss.arquillian.impl.core.ManagerImpl.<init>(ManagerImpl.java:95)
      at org.jboss.arquillian.impl.core.ManagerBuilder.create(ManagerBuilder.java:74)
      at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:97)
      at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:67)
      at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:82)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
      at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
      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.impl.domain.ContainerCreationException: Could not create Container jbossas-remote-6
      at org.jboss.arquillian.impl.domain.ContainerRegistry.create(ContainerRegistry.java:78)
      at org.jboss.arquillian.impl.client.container.ContainerRegistryCreator.createRegistry(ContainerRegistryCreator.java:67)
      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.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)
      at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)
      at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:80)
      at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:126)
      at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:106)
      at org.jboss.arquillian.impl.core.ManagerImpl.bindAndFire(ManagerImpl.java:221)
      at org.jboss.arquillian.impl.core.InstanceImpl.set(InstanceImpl.java:74)
      at org.jboss.arquillian.impl.bootstrap.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:58)
      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.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)
      at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)
      at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:80)
      at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:126)
      at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:106)
      at org.jboss.arquillian.impl.core.ManagerImpl.<init>(ManagerImpl.java:91)
      ... 22 more
      Caused by: java.lang.IllegalStateException: No implementation found for org.jboss.arquillian.spi.client.container.DeployableContainer, please check your classpath
      at org.jboss.arquillian.impl.DynamicServiceLoader.verifyOnlyOneOrSameImplementation(DynamicServiceLoader.java:134)
      at org.jboss.arquillian.impl.DynamicServiceLoader.onlyOne(DynamicServiceLoader.java:92)
      at org.jboss.arquillian.impl.domain.ContainerRegistry.create(ContainerRegistry.java:69)
      ... 45 more

       

       

      Here is a screenshot of the project in Eclipse

       

      eclipse.jpg

       

       

      Here is the jndi.properties

       

      java.naming.factory.initial= org.jnp.interfaces.NamingContextFactory  
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces   
      java.naming.provider.url=jnp://127.0.0.1:1099
      
      
      
      
      

       

       

      Here is the Arquillian.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <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="jbossas-remote-6" default="true">
        <configuration>
          <property name="providerUrl">jnp://127.0.0.1:1099</property>
        </configuration>
        <protocol type="Servlet 3.0">
         <property name="host">127.0.0.1</property>
         <property name="port">8080</property>
        </protocol>
       </container>
         
      

       

       

      And here is the POM.xml

       

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>MyFirstAQProject</groupId>
      <artifactId>MyFirstAQProject</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>jar</packaging>
      <name>MyFirstAQProject</name>
      <url>http://maven.apache.org</url>
      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <arquillian.version>1.0.0.Alpha5</arquillian.version>
      </properties>
      <pluginRepositories>
      <pluginRepository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>
      <layout>default</layout>
      </pluginRepository>
      </pluginRepositories>
      
      <build>
      <plugins> 
      <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
      <source>1.6</source>
      <target>1.6</target>
      </configuration>
      </plugin>
      </plugins>
      </build>
      
      <dependencies>
      <dependency>
      <groupId>javax.ejb</groupId>
      <artifactId>ejb-api</artifactId>
      <version>3.0</version>
      <optional>false</optional>
      </dependency> 
      <dependency>
      <groupId>javax.enterprise</groupId>
      <artifactId>cdi-api</artifactId>
      <version>1.0-SP1</version>
      <optional>false</optional>
      </dependency>
      <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-junit</artifactId>
      <version>${arquillian.version}</version>
      <scope>test</scope>
      <optional>false</optional>
      </dependency>
      <dependency>
      <groupId>org.jboss.shrinkwrap.descriptors</groupId>
      <artifactId>shrinkwrap-descriptors-api</artifactId>
      <version>0.1.4</version>
      <scope>test</scope>
      <optional>false</optional>
      </dependency>
      <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
      <optional>false</optional>
      </dependency>
      </dependencies>
      
      <profiles>
      <profile>
      <id>jbossas-remote-6</id>
      <dependencies>
      <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-jbossas-remote-6</artifactId>
      <version>${arquillian.version}</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.jboss.jbossas</groupId>
      <artifactId>jboss-as-client</artifactId>
      <version>6.0.0.Final</version>
      <type>pom</type>
      </dependency>
      </dependencies>
      </profile>
      </profiles>
      
      <repositories>
      <!-- other repos here -->
      <repository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>http://repository.jboss.org/nexus/content/groups/public/</url>
      <layout>default</layout>
      </repository>
      <repository>
      <releases>
      <enabled>true</enabled>
      </releases>
      <snapshots>
      <enabled>false</enabled>
      </snapshots>
      <id>jboss-central</id>
      <name>JBoss Central</name>
      <url>https://repository.jboss.org/nexus/content/repositories/central/</url>
      <layout>default</layout>
      </repository>
      <repository>
      <releases>
      <enabled>true</enabled>
      </releases>
      <snapshots>
      <enabled>false</enabled>
      </snapshots>
      <id>jboss-deprecated</id>
      <name>JBoss Deprecated</name>
      <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
      <layout>default</layout>
      </repository>
      <repository>
      <releases>
      <enabled>true</enabled>
      </releases>
      <snapshots>
      <enabled>false</enabled>
      </snapshots>
      <id>jboss-public</id>
      <name>JBoss Public</name>
      <url>https://repository.jboss.org/nexus/content/repositories/public-jboss/</url>
      <layout>default</layout>
      </repository>
      
      </repositories>
      
      </project>
      
        • 1. Re: Could not read active container configuration: null in Eclipse JUnit
          Aslak Knutsen Master

          You only have one container defined in arq.xml and it is marked as default, so you don't have to specify the -Darquillian.launch property. (this is confusing warning from arquillian, "Could not read container configuration: null")

           

          You don't need jndi.properties anymore, they will be ignored.

           

          I would also upgrade from 1.0.0.Alpha5 to 1.0.0.CR5 of Arquillian Core, a few things have changed, see the migration guide: http://community.jboss.org/wiki/MigrationToArquillian100CR1

           

          And use 1.0.0.CR2 of the JBoss Arquillian Container (arquillian-jbossas-remote-6).

          • 2. Re: Could not read active container configuration: null in Eclipse JUnit
            Terence To Newbie

            Thank you Aslak for the suggestion.  Sorry for the late response. 

             

            I finally have time to migrate the project to 1.0.0.CR5 as suggested. As before, I was able to run this in Maven command line, and it throws exception in Eclipse JUnit.   However, the exception is different this time. Check the Jboss log and it was never deployed to the Jboss instance.

             

            Exception:

             

            java.lang.NullPointerException
             at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:266)
             at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:202)
             at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:290)
             at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:45)
             at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:216)
             at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
             at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
             at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
             at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
             at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
             at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
             at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
             at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:161)
             at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:290)
             at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:45)
             at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:175)
             at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
             at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:123)
             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)
            
             
            
            

             

             

            It points to the methodInvoker() in the Arquillian class

             

            @Override
               protected Statement methodInvoker(final FrameworkMethod method, final Object test)
               {
                  return new Statement()
                  {
                     @Override
                     public void evaluate() throws Throwable
                     {
                        TestResult result = State.getTestAdaptor().test(new TestMethodExecutor()
                        {
                           @Override
                           public void invoke(Object... parameters) throws Throwable
                           {
                              try
                              {
                                 method.invokeExplosively(test, parameters); 
                              } 
                              catch (Throwable e) 
                              {
                                 // Force a way to return the thrown Exception from the Container the client. 
                                 State.caughtTestException(e);
                                 throw e;
                              }
                           }
                           
                           public Method getMethod()
                           {
                              return method.getMethod();
                           }
                           
                           public Object getInstance()
                           {
                              return test;
                           }
                        });
                        if(result.getThrowable() != null)
                        {
                           throw result.getThrowable();
                        }
                     }
                  };
               }
            
            

             

             

             

             

            To migrate to 1.0.0.CR5, I changed only two items in the project - the POM.xml, and the TemperatureConverterTest.java.

             

            TemperatureConverterTest.java

             

            package com.uteksoft.learning;
            import javax.ejb.EJB;
            import org.jboss.arquillian.container.test.api.Deployment;
            import org.jboss.arquillian.junit.Arquillian;
            import org.jboss.shrinkwrap.api.ShrinkWrap;
            import org.jboss.shrinkwrap.api.spec.JavaArchive;
            import org.junit.Assert;
            import org.junit.Test;
            import org.junit.runner.RunWith;
            
            @RunWith(Arquillian.class)
            public class TemperatureConverterTest {
             
             @Deployment
             public static JavaArchive createTestArchive() {
              return ShrinkWrap.create(JavaArchive.class, "test.jar").addClasses(TemperatureConverter.class, TemperatureConverterBean.class);
             }
             
             @EJB
             private TemperatureConverter converter;
             
             @Test
             public void testConvertToCelsius() {
              Assert.assertEquals(converter.convertToCelsius(212d), 100d, 0.9);
             }
             
            }
            
            

             

             

             

            POM.xml

             

            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
              <modelVersion>4.0.0</modelVersion>
              <groupId>MyFirstAQProject</groupId>
              <artifactId>MyFirstAQProject</artifactId>
              <version>1.0-SNAPSHOT</version>
              <packaging>jar</packaging>
              <name>MyFirstAQProject</name>
              <url>http://maven.apache.org</url>
              <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <arquillian.version>1.0.0.CR5</arquillian.version>
                <shrinkwrap.version>1.0.0-beta-5</shrinkwrap.version>
                <shrinkwrap_descriptor.version>1.1.0-beta-1</shrinkwrap_descriptor.version>
              </properties>
              <pluginRepositories>
               <pluginRepository>
                <id>jboss-public-repository-group</id>
                <name>JBoss Public Repository Group</name>
                <url>http://repository.jboss.org/nexus/content/groups/public/</url>
                <layout>default</layout>
               </pluginRepository>
              </pluginRepositories>
              
              <build>
                <plugins>  
                  <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                      <source>1.6</source>
                      <target>1.6</target>
                    </configuration>
                  </plugin>
                </plugins>
              </build>
             
              <dependencies>
                <dependency>
                <groupId>javax.ejb</groupId>
                <artifactId>ejb-api</artifactId>
                <version>3.0</version>
                <optional>false</optional>
               </dependency> 
               <dependency>
                <groupId>javax.enterprise</groupId>
                <artifactId>cdi-api</artifactId>
                <version>1.0-SP1</version>
                <optional>false</optional>
               </dependency>
               <dependency>
                <groupId>org.jboss.arquillian.junit</groupId>
                <artifactId>arquillian-junit-container</artifactId>
                <version>${arquillian.version}</version>
                <scope>test</scope>
                <optional>false</optional>
               </dependency>
               <dependency>
                    <groupId>org.jboss.shrinkwrap.descriptors</groupId>
                    <artifactId>shrinkwrap-descriptors-api</artifactId>
                    <version>${shrinkwrap_descriptor.version}</version>
                    <scope>test</scope>
                    <optional>false</optional>
                </dependency>
               <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.8.1</version>
                <scope>test</scope>
                <optional>false</optional>
               </dependency>
              </dependencies>
              
              <profiles>
             <profile>
              <id>jbossas-remote-6</id>
              <dependencies>
               <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-jbossas-remote-6</artifactId>
                <version>1.0.0.CR2</version>
                <scope>test</scope>
               </dependency>
               <dependency>
                <groupId>org.jboss.jbossas</groupId>
                <artifactId>jboss-as-client</artifactId>
                <version>6.0.0.Final</version>
                <type>pom</type>
               </dependency>
              </dependencies>
             </profile>
              </profiles>
              
              <repositories>
             <!-- other repos here -->
               <repository>
                <id>jboss-public-repository-group</id>
                <name>JBoss Public Repository Group</name>
                <url>http://repository.jboss.org/nexus/content/groups/public/</url>
                <layout>default</layout>
               </repository>
               <repository>
                <releases>
                 <enabled>true</enabled>
                </releases>
                <snapshots>
                 <enabled>false</enabled>
                </snapshots>
                <id>jboss-central</id>
                <name>JBoss Central</name>
                <url>https://repository.jboss.org/nexus/content/repositories/central/</url>
                <layout>default</layout>
               </repository>
               <repository>
                <releases>
                 <enabled>true</enabled>
                </releases>
                <snapshots>
                 <enabled>false</enabled>
                </snapshots>
                <id>jboss-deprecated</id>
                <name>JBoss Deprecated</name>
                <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
                <layout>default</layout>
               </repository>
               <repository>
                <releases>
                 <enabled>true</enabled>
                </releases>
                <snapshots>
                 <enabled>false</enabled>
                </snapshots>
                <id>jboss-public</id>
                <name>JBoss Public</name>
                <url>https://repository.jboss.org/nexus/content/repositories/public-jboss/</url>
                <layout>default</layout>
               </repository>
               
              </repositories>
             
            </project>
            
            
            • 3. Re: Could not read active container configuration: null in Eclipse JUnit
              Terence To Newbie

              I have also attached the entire project here. Any suggestion is greatly appreciated.

              Thank you.