1 Reply Latest reply: May 30, 2011 4:52 AM by Aslak Knutsen RSS

Arquillian and seam problem

Branislav Vrtunski Newbie

Hello,

 

I am developing app that i wanna test with arquillian alpha 5. When i test beans that have properties managed by seam extensions i

always get "unsatisfied dependecies error" . I am using seam solder module and seam servlet module. Beans that have Logger and Servlet Context injected fail when being tested.

My pom :

 

<profile>

            <id>arq-weld-embedded</id>

            <activation>

                <property>

                    <name>!arquillian</name>

                </property>

            </activation>

            <dependencies>

                <dependency>

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

                    <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>

                    <scope>test</scope>

                </dependency>

                <!-- Arquillian Weld EE Embedded requires the EL and EJB 3.1 APIs; Weld

                    runtime provided by weld-servlet -->

                <dependency>

                    <groupId>javax.el</groupId>

                    <artifactId>el-api</artifactId>

                    <!-- remove scope if bundling EL libraries w/ webapp -->

                    <scope>test</scope>

                </dependency>

                <dependency>

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

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

                    <version>1.0.0.Final</version>

                    <scope>test</scope>

                </dependency>

                <dependency>

                    <groupId>org.jboss.weld.servlet</groupId>

                    <artifactId>weld-tomcat-support</artifactId>

                    <version>1.0.1-CR2</version>

                    <scope>test</scope>

                </dependency>

             

                    <dependency>

                        <groupId>org.jboss.seam.servlet</groupId>

                        <artifactId>seam-servlet</artifactId>

                        <version>3.0.0.Final</version>

                        <scope>test</scope>

                    </dependency>

                    <dependency>

                        <groupId>javax.servlet</groupId>

                        <artifactId>servlet-api</artifactId>

                        <version>2.5</version> 

                   

                    </dependency>

                    <dependency>

                        <groupId>org.jboss.logging</groupId>

                        <artifactId>jboss-logging</artifactId>

                        <version>3.0.0.Beta1</version>

                        <scope>test</scope>

                    </dependency>

                    <dependency>

                        <groupId>org.hibernate</groupId>

                        <artifactId>hibernate-entitymanager</artifactId>

                        <version>3.6.0.Final</version>

                        <scope>test</scope>

                    </dependency>

                </dependencies>

            </profile>

 

Exact exception :

 

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ServletContext] with qualifiers [@Default] at injection point [[field] @Inject private biz.netdialog.properties.PropertyUtil.sc

 

Test:

 

@Deployment

    public static Archive<?> createTestArchive() {

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

                .addLibraries(MavenArtifactResolver.resolve("org.jboss.seam.solder", "seam-solder"),MavenArtifactResolver.resolve("org.jboss.weld.servlet", "weld-servlet"))

                .addClass(HelloWorld.class)

                .addClass(EntityManagerPool.class)

                .addClass(SessionData.class)

                .addClass(NetXDB.class)

                .addClass(MockServletContext.class)

                .addClass(DBProperties.class)

                .addClass(ServletContext.class)

                .addClass(PropertyUtil.class)               

                .addWebResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))

                .addManifestResource("test-persistence.xml",ArchivePaths.create("persistence.xml"));

        System.out.println(war.toString(true));

        return war;

  • 1. Re: Arquillian and seam problem
    Aslak Knutsen Master

    The Weld EE Mock container is not 100% working when it comes to nested jars in deployments etc, so it probably never reads the Seam Solder Extension at all.

     

    A possible fix is to import the Seam Solder library as a ShrinkWrap archive and add it to your deployment.

     

    something like:

     

    ShrinkWrap.create(WebArchive.class, "test.war").addLibrary(
        ShrinkWrap.createFromZipFile(JavaArchive.class, MavenResolver.resolve(...)));
    

     

    FYI: Weld EE is just a mock environment, so ServletContext will be a mocked version not doing much. I fyou need a real one you should move to a servlet container, e.g. JBoss AS , GlassFish, Jetty or Tomcat.

     

    -aslak-