Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-1001

Bean not injected with CDI and Aquirlian test failed when SolrServer is used

    Details

    • Steps to Reproduce:
      Hide

      My Arquillian test looks like this:

      import static org.junit.Assert.assertNotNull;
      import static org.junit.Assert.assertTrue;
      import javax.enterprise.inject.spi.CDI;
      import javax.inject.Inject;
      import org.jboss.arquillian.junit.Arquillian;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      import org.wildfly.swarm.arquillian.DefaultDeployment;

      @RunWith(Arquillian.class)
      @DefaultDeployment(type = Type.WAR)
      public class CDIArquillianTest {

      @Inject
      private SomeClass someclass;

      @Test
      public void testInjection()

      { assertNotNull(someclass); assertTrue(someclass.printI().contains("my string")); }

      @Test
      public void testCDIContainerPresence() throws Exception

      { assertNotNull(CDI.current()); }

      }

      Injected class:

      import javax.enterprise.context.ApplicationScoped;
      import org.apache.solr.client.solrj.SolrServer;

      @ApplicationScoped
      public class SomeClass{
      private SolrServer solrServer;

      public SomeClass(){
      }

      public String printI()

      { String somestr = "my string"; return somestr; }


      }
      Inside of it, there is SolrServer class, which makes the problem. Without the class inclussion, everything works fine.

      pom.xml:

      <packaging>war</packaging>

      <properties>
      <version.wildfly.swarm>2017.1.1</version.wildfly.swarm>
      <version.wildfly.arquillian>1.1.10.Final</version.wildfly.arquillian>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
      <failOnMissingWebXml>false</failOnMissingWebXml>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <solr.version>4.10.3-cdh5.9.0</solr.version>
      </properties>

      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>bom-all</artifactId>
      <version>${version.wildfly.swarm}</version>
      <scope>import</scope>
      <type>pom</type>
      </dependency>
      <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>${version.wildfly.arquillian}</version>
      <type>pom</type>
      <scope>import</scope>
      </dependency>
      </dependencies>
      </dependencyManagement>
      <dependencies>
      <!-- Java EE 7 dependency -->
      <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>7.0</version>
      <scope>provided</scope>
      </dependency>

      <!-- Wildfly Swarm Fractions -->
      <dependency>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>logging</artifactId>
      </dependency>
      <dependency>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>jaxrs-validator</artifactId>
      </dependency>
      <dependency>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>cdi</artifactId>
      </dependency>

      <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-core</artifactId>
      <version>2.6.0-mr1-cdh5.7.4</version>
      <scope>provided</scope>
      </dependency>
      <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-common</artifactId>
      <version>2.6.0-cdh5.7.4</version>
      <scope>provided</scope>
      </dependency>
      <!-- Solar -->
      <dependency>
      <groupId>org.apache.solr</groupId>
      <artifactId>solr-solrj</artifactId>
      <version>${solr.version}</version>
      </dependency>
      <dependency>
      <groupId>org.apache.solr</groupId>
      <artifactId>solr-core</artifactId>
      <version>${solr.version}</version>
      </dependency>
      <dependency>
      <groupId>org.apache.solr</groupId>
      <artifactId>solr-cell</artifactId>
      <version>${solr.version}</version>
      </dependency>

      <!-- Other Dependencies -->
      <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.2</version>
      <scope>provided</scope>
      </dependency>

      <!-- Test Dependencies -->
      <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.wildfly.swarm</groupId>
      <artifactId>arquillian</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
      </dependency>

      <dependency>
      <groupId>org.skyscreamer</groupId>
      <artifactId>jsonassert</artifactId>
      <version>1.4.0</version>
      <scope>test</scope>
      </dependency>
      </dependencies>

      Show
      My Arquillian test looks like this: import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import javax.enterprise.inject.spi.CDI; import javax.inject.Inject; import org.jboss.arquillian.junit.Arquillian; import org.junit.Test; import org.junit.runner.RunWith; import org.wildfly.swarm.arquillian.DefaultDeployment; @RunWith(Arquillian.class) @DefaultDeployment(type = Type.WAR) public class CDIArquillianTest { @Inject private SomeClass someclass; @Test public void testInjection() { assertNotNull(someclass); assertTrue(someclass.printI().contains("my string")); } @Test public void testCDIContainerPresence() throws Exception { assertNotNull(CDI.current()); } } Injected class: import javax.enterprise.context.ApplicationScoped; import org.apache.solr.client.solrj.SolrServer; @ApplicationScoped public class SomeClass{ private SolrServer solrServer; public SomeClass(){ } public String printI() { String somestr = "my string"; return somestr; } } Inside of it, there is SolrServer class, which makes the problem. Without the class inclussion, everything works fine. pom.xml: <packaging>war</packaging> <properties> <version.wildfly.swarm>2017.1.1</version.wildfly.swarm> <version.wildfly.arquillian>1.1.10.Final</version.wildfly.arquillian> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <failOnMissingWebXml>false</failOnMissingWebXml> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <solr.version>4.10.3-cdh5.9.0</solr.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>bom-all</artifactId> <version>${version.wildfly.swarm}</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.jboss.arquillian</groupId> <artifactId>arquillian-bom</artifactId> <version>${version.wildfly.arquillian}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- Java EE 7 dependency --> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency> <!-- Wildfly Swarm Fractions --> <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>logging</artifactId> </dependency> <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>jaxrs-validator</artifactId> </dependency> <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>cdi</artifactId> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-core</artifactId> <version>2.6.0-mr1-cdh5.7.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <version>2.6.0-cdh5.7.4</version> <scope>provided</scope> </dependency> <!-- Solar --> <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> <version>${solr.version}</version> </dependency> <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-core</artifactId> <version>${solr.version}</version> </dependency> <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-cell</artifactId> <version>${solr.version}</version> </dependency> <!-- Other Dependencies --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.2</version> <scope>provided</scope> </dependency> <!-- Test Dependencies --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>arquillian</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.skyscreamer</groupId> <artifactId>jsonassert</artifactId> <version>1.4.0</version> <scope>test</scope> </dependency> </dependencies>

      Description

      Inside of my test code, there is SolrServer class, which makes a problem. Without the class inclussion, everything works fine. Maybe SolrServer is somehow incompatible with CDI?
      Error message on JUnit test output:

      java.lang.RuntimeException: Could not inject members
      at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:135)
      at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.enrich(CDIInjectionEnricher.java:78)
      at org.jboss.arquillian.test.impl.TestInstanceEnricher.enrich(TestInstanceEnricher.java:52)
      ...
      at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
      at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
      at java.lang.Thread.run(Thread.java:745)
      Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: org.jboss.weld.exceptions.IllegalArgumentException : WELD-001408: Unsatisfied dependencies for type SomeClass with qualifiers @Default
      at injection point [BackedAnnotatedField] @Inject private xx.CDIArquillianTest.someclass
      at xx.CDIArquillianTest.someclass(CDIArquillianTest.java:0)
      [Proxied because : Original exception caused: class java.lang.ClassNotFoundException: org.jboss.weld.exceptions.IllegalArgumentException]
      at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:81)
      at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:69)
      at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:1110)
      at org.jboss.weld.util.ForwardingBeanManager.createInjectionTarget(ForwardingBeanManager.java:201)
      at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectNonContextualInstance(CDIInjectionEnricher.java:143)
      at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:125)
      ... 115 more
      Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: org.jboss.weld.exceptions.DeploymentException : WELD-001408: Unsatisfied dependencies for type SomeClass with qualifiers @Default
      at injection point [BackedAnnotatedField] @Inject private xx.CDIArquillianTest.someclass
      at xx.CDIArquillianTest.someclass(CDIArquillianTest.java:0)
      [Proxied because : Original exception caused: class java.lang.ClassNotFoundException: org.jboss.weld.exceptions.DeploymentException]
      at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
      at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
      at org.jboss.weld.bootstrap.Validator.validateProducer(Validator.java:417)
      at org.jboss.weld.injection.producer.InjectionTargetService.validateProducer(InjectionTargetService.java:36)
      at org.jboss.weld.manager.InjectionTargetFactoryImpl.validate(InjectionTargetFactoryImpl.java:135)
      at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:79)
      ... 120 more

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mkouba Martin Kouba
                Reporter:
                mmielniczek Miroslaw M
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: