1 Reply Latest reply on Apr 11, 2013 9:44 AM by Bartosz Majsak

    Unable to inject dependencies of injected bean with Arquillian

    tzachi strugo Newbie

      Hi,

       

      I am new in arquillian project.

       

      I have some issues with DI. arquillian success to deploy on my JBOSS 7.1.1. but it failed on inject HelloWorld class to my test.

      Therefor my test always failing

       

      i will appreciate your help with my issue

      Thanks in advance

       

      Test

      package com.netapp.noc.rs.activation.cloud.dao;

       

       

      import com.netapp.noc.rs.cloud.dao.HelloWorld;

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

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.ArchivePaths;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

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

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

      import org.junit.Assert;

      import org.junit.Test;

      import org.junit.runner.RunWith;

      import javax.inject.Inject;

       

       

      @RunWith(Arquillian.class)

      public class PlanDaoTest {

       

       

          @Inject

          private HelloWorld helloWorld;

       

       

          @Deployment

          public static JavaArchive createDeployment(){

               JavaArchive archive = ShrinkWrap.create(JavaArchive.class)

                      .addClass(HelloWorld.class)

                    .addAsManifestResource(new ByteArrayAsset("<beans></beans>".getBytes()),

                            ArchivePaths.create("beans.xml"));

       

       

              return archive;

             }

       

       

       

       

         @Test

         public void testHelloWorld(){

       

       

               Assert.assertNotNull(helloWorld);

              String expected = "duke";

              String hello = helloWorld.hello(expected);

              Assert.assertNotNull(hello);

         }

      }

       

       

      Class

      package com.netapp.noc.rs.cloud.dao;

       

       

      import javax.ejb.Stateless;

       

       

      @Stateless

      public class HelloWorld {

       

       

          public String hello(String message){

       

              return "Echo: " + message;

       

           }

        }

       

       

      POM

       

      <?xml version="1.0" encoding="UTF-8"?>

      <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>com.netapp.noc</groupId>

          <artifactId>noc</artifactId>

          <version>1.0</version>

          <packaging>war</packaging>

       

       

          <properties>

            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

            <version.arquillian_core>1.0.0.CR7</version.arquillian_core>

          </properties>

       

       

          <dependencies>

              <dependency>

                  <groupId>org.jboss.resteasy</groupId>

                  <artifactId>resteasy-links</artifactId>

                  <version>2.3.4.Final</version>

              </dependency>

              <dependency>

                  <groupId>org.jboss.resteasy</groupId>

                  <artifactId>resteasy-jaxb-provider</artifactId>

                  <version>2.3.4.Final</version>

                  <scope>provided</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.resteasy</groupId>

                  <artifactId>resteasy-jaxrs</artifactId>

                  <version>2.3.4.Final</version>

                  <scope>provided</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.resteasy</groupId>

                  <artifactId>tjws</artifactId>

                  <version>2.3.4.Final</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

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

                  <artifactId>jboss-ejb-api_3.1_spec</artifactId>

                  <version>1.0.1.Final</version>

                  <scope>provided</scope>

              </dependency>

              <dependency>

                  <groupId>org.hibernate.javax.persistence</groupId>

                  <artifactId>hibernate-jpa-2.0-api</artifactId>

                  <version>1.0.1.Final</version>

                  <scope>provided</scope>

              </dependency>

              <dependency>

                  <groupId>org.hibernate</groupId>

                  <artifactId>hibernate-entitymanager</artifactId>

                  <version>4.0.1.Final</version>

                  <scope>provided</scope>

              </dependency>

       

       

              <dependency>

                  <groupId>org.jboss</groupId>

                  <artifactId>jboss-vfs</artifactId>

                  <version>3.1.0.Final</version>

                  <scope>provided</scope>

              </dependency>

       

       

              <dependency>

                  <groupId>commons-beanutils</groupId>

                  <artifactId>commons-beanutils</artifactId>

                  <version>1.8.3</version>

                  <!--<scope>provided</scope>-->

              </dependency>

       

       

               <dependency>

                  <groupId>junit</groupId>

                  <artifactId>junit</artifactId>

                  <version>4.10</version>

                  <scope>test</scope>

              </dependency>

       

       

               <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.arquillian.junit</groupId>

            <artifactId>arquillian-junit-container</artifactId>

            <scope>test</scope>

          </dependency>

       

       

              <dependency>

             <groupId>org.jboss.shrinkwrap</groupId>

             <artifactId>shrinkwrap-api</artifactId>

           </dependency>

           <dependency>

             <groupId>org.jboss.shrinkwrap</groupId>

             <artifactId>shrinkwrap-impl-base</artifactId>

             <scope>test</scope> <!-- Don't rely upon internals for compilation -->

           </dependency>

           <dependency>

            <groupId>javax.enterprise</groupId>

            <artifactId>cdi-api</artifactId>

            <scope>provided</scope>

          </dependency>

          <dependency>

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

            <artifactId>jboss-annotations-api_1.1_spec</artifactId>

            <scope>provided</scope>

          </dependency>

              <dependency>

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

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

                  <version>7.1.1.Final</version>

              </dependency>

       

       

               <dependency>

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

            <artifactId>jboss-servlet-api_3.0_spec</artifactId>

            <scope>provided</scope>

          </dependency>

          <dependency>

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

            <artifactId>jboss-jsf-api_2.1_spec</artifactId>

            <scope>provided</scope>

          </dependency>

          <dependency>

            <groupId>org.jboss.spec.javax.ws.rs</groupId>

            <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>

            <scope>provided</scope>

          </dependency>

          </dependencies>

       

       

       

       

           <dependencyManagement>

          <dependencies>

            <dependency>

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

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

              <version>3.0.1.Final</version>

              <type>pom</type>

              <scope>import</scope>

            </dependency>

            <dependency>

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

              <artifactId>arquillian-bom</artifactId>

              <version>${version.arquillian_core}</version>

              <type>pom</type>

              <scope>import</scope>

            </dependency>

          </dependencies>

        </dependencyManagement>

       

       

       

       

          <build>

              <plugins>

                  <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-compiler-plugin</artifactId>

                      <version>2.3.2</version>

                      <configuration>

                          <source>1.7</source>

                          <target>1.7</target>

                      </configuration>

                  </plugin>

       

       

                  <!--<plugin>-->

                      <!--<artifactId>maven-war-plugin</artifactId>-->

                      <!--<configuration>-->

                          <!--<archive>-->

                              <!--<manifestEntries>-->

                                  <!--<Dependencies>org.apache.httpcomponents</Dependencies>-->

                              <!--</manifestEntries>-->

                          <!--</archive>-->

                      <!--</configuration>-->

                  <!--</plugin>-->

       

       

                  <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-antrun-plugin</artifactId>

                      <version>1.6</version>

       

       

                      <executions>

                          <execution>

                              <id>Copy WAR to JBoss's deploy</id>

                              <phase>install</phase>

                              <configuration>

                                  <target>

                                      <property file="build.properties"/>

                                      <copy todir="${jboss.deploy.dir}">

                                          <fileset file="${project.build.directory}/*.war"/>

                                      </copy>

                                  </target>

                              </configuration>

                              <goals>

                                  <goal>run</goal>

                              </goals>

                          </execution>

                      </executions>

                  </plugin>

                  <plugin>

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

                      <version>2.12</version>

                  </plugin>

              </plugins>

          </build>

           <profiles>

          <profile>

          <id>jbossas-remote-7</id>

          <dependencies>

              <dependency>

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

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

                  <version>7.1.1.Final</version>

                  <scope>test</scope>

              </dependency>

          </dependencies>

      </profile>

        </profiles>

       

       

          <repositories>

              <repository>

                  <snapshots>

                      <enabled>false</enabled>

                  </snapshots>

                  <id>central</id>

                  <name>libs-releases</name>

                  <url>http://artifactory.tlveng.netapp.com:8081/artifactory/libs-releases</url>

              </repository>

              <repository>

                  <snapshots/>

                  <id>snapshots</id>

                  <name>libs-snapshots</name>

                  <url>http://artifactory.tlveng.netapp.com:8081/artifactory/libs-snapshots</url>

              </repository>

       

       

              <repository>

                <id>JBOSS_NEXUS</id>

                <url>http://repository.jboss.org/nexus/content/groups/public</url>

              </repository>

       

       

          </repositories>

          <pluginRepositories>

              <pluginRepository>

                  <snapshots>

                      <enabled>false</enabled>

                  </snapshots>

                  <id>central</id>

                  <name>plugins-releases</name>

                  <url>http://artifactory.tlveng.netapp.com:8081/artifactory/plugins-releases</url>

              </pluginRepository>

              <pluginRepository>

                  <snapshots/>

                  <id>snapshots</id>

                  <name>plugins-snapshots</name>

                  <url>http://artifactory.tlveng.netapp.com:8081/artifactory/plugins-snapshots</url>

              </pluginRepository>

          </pluginRepositories>

       

       

      </project>

       

       

      Env

      JBOSS 7.1.1


       

      Message was edited by: tzachi strugo