Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-619

If multiple DeployableContainers are in the classpath the exception message is currently incorrect

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 1.0.0.CR5
    • 1.0.0.Final
    • None
    • None

    Description

      I 've configured both arquillian-jetty-embedded-6.1 and jboss-as-arquillian-container-managed in my pom.xml.

      As a result of some weird exception based code in arquillian, I get this stacktrace which tells me it's another problem (which it is not):

      org.jboss.arquillian.container.test.impl.client.deployment.ValidationException: DeploymentScenario contains targets not matching any defined Container in the registry. _DEFAULT_. Possible causes are: No Deployable Container found on Classpath or your have defined a @org.jboss.arquillian.container.test.api.Deployment with a @org.jboss.arquillian.container.test.api.TargetsContainer value that does not match any found/configured Containers (see arquillian.xml container@qualifier) 
      	at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.validate(DeploymentGenerator.java:102)
      	at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:84)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
      	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.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
      	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
      	at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
      	at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:96)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
      	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.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:68)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:54)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
      	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
      	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
      	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
      	at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
      	at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:158)
      	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.junit.runner.JUnitCore.run(JUnitCore.java:157)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      

      So, what happened?
      The method org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader#onlyOne
      throw an exception:

         public <T> T onlyOne(Class<T> serviceClass)
         {
            Collection<T> all = all(serviceClass);
            if(all.size() == 1)
            {
               return all.iterator().next();
            }
            if(all.size() > 1)
            {
               throw new IllegalStateException("Multiple service implementations found for " + serviceClass + ". " + toClassString(all)); // <================ GOOD
            }
            return null;
         }
      

      and the method org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator#createRegistry
      swept it under the covers:

         public void createRegistry(@Observes ArquillianDescriptor event)
         {
            ...
            if(activeConfiguration == null && reg.getContainers().size() == 0)
            {
               try
               {
                  DeployableContainer<?> deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
                  if(deployableContainer != null)
                  {
                     reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
                  }
               } 
               catch (Exception e) 
               {
                  // ignore // <====================================================== BAD
               }
            }
      
            // export
            registry.set(reg);
         }
      

      Attachments

        Issue Links

          Activity

            People

              aslak@redhat.com Aslak Knutsen
              gdesmet@redhat.com Geoffrey De Smet
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: