5 Replies Latest reply on Sep 2, 2011 3:40 AM by Thierry Ler

    Named bean not scanned in a Maven multi module project

    Thierry Ler Newbie

      Hello.


      I created a new Seam 3 project using the Maven archetype as described on the getting started page (http://seamframework.org/Documentation/CDIQuickstartForMavenUsers) :


      mvn archetype:generate -DarchetypeArtifactId=jboss-jsf-weld-servlet-webapp -DarchetypeGroupId=org.jboss.weld.archetypes -DarchetypeVersion=1.0.1.Beta1 -DarchetypeRepository=central



      Then I added a named bean :



      @Named
      public class IdefixDog {
           public String getName() {
                return "Idefix";
           }
      }



      And I used the named bean in index.xhtml :


      <h3>Dog 2 name: #{idefixDog.name}</h3>



      It worked !
      (Tomcat 6, Eclipse Indigo, JBoss Tool 3.3, JDK 1.6)


      Then I transformed the project into a Maven multi module project.


      The parent pom :


      <project >
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.ice</groupId>
        <artifactId>seam3-test</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>pom</packaging>
      
        <modules>
          <module>seam3-test-model</module>
          <module>seam3-test-web</module>
        </modules>



      The seam3-test-model pom :


      <project >
           <modelVersion>4.0.0</modelVersion>
           <parent>
                <groupId>com.ice</groupId>
                <artifactId>seam3-test</artifactId>
                <version>1.0-SNAPSHOT</version>
           </parent>
      
           <groupId>com.ice</groupId>
           <artifactId>seam3-test-model</artifactId>
           <version>1.0-SNAPSHOT</version>
           <packaging>jar</packaging>



      The seam3-test-web pom :


      <project >
           <modelVersion>4.0.0</modelVersion>
      
           <parent>
                <groupId>com.ice</groupId>
                <artifactId>seam3-test</artifactId>
                <version>1.0-SNAPSHOT</version>
           </parent>
      
           <groupId>com.ice</groupId>
           <artifactId>seam3-test-web</artifactId>
           <version>1.0-SNAPSHOT</version>
           <packaging>war</packaging>
      
           <dependencies>
                <dependency>
                     <groupId>com.ice</groupId>
                     <artifactId>seam3-test-model</artifactId>
                     <version>1.0-SNAPSHOT</version>
                </dependency>



      Then I added a new named bean in the seam3-test-model module :


      @Named
      public class MilouDog {
           public String getName() {
                return "Milou";
           }
      }



      And I used the milou bean in index.xhtml :


      <h3>Dog 1 name: #{milouDog.name}</h3>
      <h3>Dog 2 name: #{idefixDog.name}</h3>



      BUT it only prints Idefix (ie. it does not print Milou). It works if I move the milou bean into the web module.


      I guest it only scan the web module. How can I make the model module to be scanned ? What is the propest issue, the good way ?


      Help.
      Th.