6 Replies Latest reply on Apr 20, 2010 6:49 PM by Pete Muir

    Building the Weld JSF examples

    Arbi Sookazian Master

      I recall having problems in the recent past and posting about it here about building the JSF examples in the Weld distro using maven (or possibly ant?).  The problem now with login app, for example, was that the 2.0.2-FCS JSF jar was not in the mvn repo and thus the dependency was not resolving.  So I had to manually add it to the local repo using mvn deploy:deploy-file as mvn so kindly instructs.  Well that takes a while.  The command looks like this:


      C:\java\weld-1.0.1-Final\examples\jsf\login>mvn deploy:deploy-file -DgroupId=javax.faces -DartifactId=jsf-impl -Dversion=2.0.2-FCS -Dpackaging=jar -Dfile=C:\java\jboss-6.0.0.20100216-M2\server\default\deploy\jbossweb.sar\jsf-libs\jsf-impl.jar -Durl="file://C:\Documents and Settings\asookazian\.m2\repository"


      and do it for both the jsf-api.jar and the jsf-impl.jar.  The build fails.


      Then I just read the release notes for 1.0.1-final and lo and behold the easy way:


      * If using Maven, some artifacts are only available in the JBoss Repository. To allow Weld to correctly function, add the JBoss Repository to Maven. Edit your ~/.m2/settings.xml, and add:
      
            <profile>
               <id>jboss.repository</id>
               <activation>
                  <activeByDefault>true</activeByDefault>
               </activation>
               <repositories>
                  <repository>
                     <id>repository.jboss.org</id>
                     <url>http://repository.jboss.org/maven2</url>
                     <releases>
                        <enabled>true</enabled>
                     </releases>
                     <snapshots>
                        <enabled>false</enabled>
                     </snapshots>
                  </repository>
               </repositories>
            </profile>



      So I did that, saved changes, opened a new cmd prompt in Windows XP and then try to build the numberguess example:


      C:\java\weld-1.0.1-Final\examples\jsf\numberguess>mvn clean install
      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Weld Examples: Numberguess
      [INFO]    task-segment: [clean, install]
      [INFO] ------------------------------------------------------------------------
      [INFO] [clean:clean {execution: default-clean}]
      [INFO] Deleting file set: C:\java\weld-1.0.1-Final\examples\jsf\numberguess\targ
      et (included: [**], excluded: [])
      [INFO] Deleting file set: C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\
      main\webapp (included: [WEB-INF/classes/**, WEB-INF/lib/**, META-INF/context.xml
      , WEB-INF/web.xml, WEB-INF/jetty-env.xml, WEB-INF/appengine-web.xml, WEB-INF/log
      ging.properties], excluded: [])
      [INFO] [junction:unlink {execution: unlink}]
      [INFO] [enforcer:enforce {execution: enforce}]
      [INFO] [build-helper:maven-version {execution: default}]
      [INFO] [build-helper:parse-version {execution: default}]
      [INFO] [buildnumber:create {execution: set-build-properties}]
      [INFO] Checking for local modifications: skipped.
      [INFO] Updating project files from SCM: skipped.
      [INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
      [INFO] Working directory: C:\java\weld-1.0.1-Final\examples\jsf\numberguess
      Provider message:
      The svn command failed.
      Command output:
      svn: '.' is not a working copy
      
      [WARNING] Cannot get the revision information from the scm repository, proceedin
      g with revision of unavailable :
      Error!
      [INFO] Storing buildNumber: unavailable at timestamp: April 19, 2010 11:39:33 AM
       PDT
      [INFO] [resources:resources {execution: default-resources}]
      [INFO] Using 'UTF-8' encoding to copy filtered resources.
      [INFO] skip non existing resourceDirectory C:\java\weld-1.0.1-Final\examples\jsf
      \numberguess\src\main\resources
      [INFO] [compiler:compile {execution: default-compile}]
      [INFO] Compiling 4 source files to C:\java\weld-1.0.1-Final\examples\jsf\numberg
      uess\target\classes
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Compilation failure
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[8,31] package javax.faces.application does not ex
      ist
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[9,29] package javax.faces.component does not exis
      t
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[10,29] package javax.faces.component does not exi
      st
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[11,27] package javax.faces.context does not exist
      
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[98,35] cannot find symbol
      symbol  : class FacesContext
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[98,58] cannot find symbol
      symbol  : class UIComponent
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[83,64] cannot find symbol
      symbol  : class FacesMessage
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[83,9] cannot find symbol
      symbol  : variable FacesContext
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[102,9] cannot find symbol
      symbol  : class FacesMessage
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[102,36] cannot find symbol
      symbol  : class FacesMessage
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[104,11] cannot find symbol
      symbol  : class UIInput
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[111,11] cannot find symbol
      symbol  : class UIInput
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[113,9] cannot find symbol
      symbol  : class FacesMessage
      location: class org.jboss.weld.examples.numberguess.Game
      
      C:\java\weld-1.0.1-Final\examples\jsf\numberguess\src\main\java\org\jboss\weld\e
      xamples\numberguess\Game.java:[113,36] cannot find symbol
      symbol  : class FacesMessage
      location: class org.jboss.weld.examples.numberguess.Game
      
      
      [INFO] ------------------------------------------------------------------------
      [INFO] For more information, run Maven with the -e switch
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 3 seconds
      [INFO] Finished at: Mon Apr 19 11:39:34 PDT 2010
      [INFO] Final Memory: 21M/39M
      [INFO] ------------------------------------------------------------------------



      Anybody else seeing this???  Looks like JSF JARs not in classpath.  Is that b/c I did not set my JBOSS_HOME?  Note the SCM repo warning...


      I noticed the instructions for build in the ref doc mostly discuss using ant, not maven...


      Getting the same results (compilation failures) when I run 'ant'.  So what is wrong??


        • 1. Re: Building the Weld JSF examples
          Arbi Sookazian Master

          Ok, so it would be good to actually view the build.xml.  It basically invokes two different maven lifecycle phases via the Maven macrodef in the parent build.xml (clean and install).


          But this needs to be cleaned up as well, no?


          <project basedir="." name="Numberguess Example Build" default="restart">
               
               <property name="example.name" value="weld-numberguess" />
          
               <import file="../../build.xml" />
               
             <target name="package">
                <maven target="install" basedir="${basedir}">
                   <arg line="-Pjboss5" />
                </maven>
             </target>
             
             <target name="clean">
                <maven target="clean" basedir="${basedir}">
                     <arg line="-Pjboss5" />
                </maven>
             </target>
               
          </project>



          The name of the example has been changed from weld-numberguess to numberguess so that property value above is incorrect.


          Also, why is it hard-coding -Pjboss5 as an argument to the cmd line when invoking mvn?  What if we're using jboss6, do we simply have to override that manually by typing:


          ant clean -Pjboss6



          or similar or what?

          • 2. Re: Building the Weld JSF examples
            Arbi Sookazian Master

            Here's some more data via mvn help:active-profiles:


            C:\java\weld-1.0.1-Final\examples\jsf\numberguess>mvn help:active-profiles
            [INFO] Scanning for projects...
            [INFO] Searching repository for plugin with prefix: 'help'.
            [INFO] ------------------------------------------------------------------------
            [INFO] Building Weld Examples: Numberguess
            [INFO]    task-segment: [help:active-profiles] (aggregator-style)
            [INFO] ------------------------------------------------------------------------
            [INFO] [help:active-profiles {execution: default-cli}]
            [INFO]
            Active Profiles for Project 'org.jboss.weld.examples.jsf:weld-jsf-numberguess:wa
            r:1.0.1-Final':
            
            The following profiles are active:
            
             - jboss5 (source: pom)
             - jboss.repository (source: settings.xml)
             - environment (source: settings.xml)
             - jboss.repository (source: settings.xml)
             - environment (source: settings.xml)
            
            
            
            [INFO] ------------------------------------------------------------------------
            [INFO] BUILD SUCCESSFUL
            [INFO] ------------------------------------------------------------------------
            [INFO] Total time: 1 second
            [INFO] Finished at: Mon Apr 19 15:58:24 PDT 2010
            [INFO] Final Memory: 10M/19M
            [INFO] ------------------------------------------------------------------------



            1) it would be nice if the output was specific as to which settings.xml is the source (typically there are two settings.xml files)
            2) why is jboss5 an active profile?  most users will be using JBoss6 with Weld, no?

            • 3. Re: Building the Weld JSF examples
              Arbi Sookazian Master

              Ok, so I was able to build se\hello-world and the ~/.m2/settings.xml changes is being picked up by Maven:


              [INFO] Unable to find resource 'org.jboss.weld:weld-se:pom:1.0.1-Final' in repository repository.jboss.org (http://repository.jboss.org/maven2)
              Downloading: http://repo1.maven.org/maven2/org/jboss/weld/weld-se/1.0.1-Final/weld-se-1.0.1-Final.pom



              I guess I must have installed the wrong JSF 2.0.2-FCS JARs somehow...

              • 4. Re: Building the Weld JSF examples
                Arbi Sookazian Master

                Yep, that was it.  The one I installed via mvn deploy:deploy-file goal execution had a package that started with com.foo.bar and this one starts with javax.foo.bar.  After I deleted the directories from my local mvn repo and then ran 'mvn clean install', I see this:


                Downloading: http://repository.jboss.org/maven2/javax/faces/jsf-api/2.0.2-FCS/jsf-api-2.0.2-FCS.pom
                395b downloaded  (jsf-api-2.0.2-FCS.pom)
                Downloading: http://repository.jboss.org/maven2/javax/faces/jsf-api/2.0.2-FCS/jsf-api-2.0.2-FCS.jar
                580K downloaded  (jsf-api-2.0.2-FCS.jar)



                Also, it did not install the the 2.0.2-FCS jsf-impl.jar.


                Wow, what a disaster.


                I would recommend that the release-notes.txt located in the root of the Weld distro be noted in the readme.txt for each example, etc. or similar.


                For dummies like me of course ;)


                Or how bout adding the following xml snippet to the parent POM for the examples???  Then what happened to me can't happen again (or less likely)...


                <profile>
                         <id>jboss.repository</id>
                         <activation>
                            <activeByDefault>true</activeByDefault>
                         </activation>
                         <repositories>
                            <repository>
                               <id>repository.jboss.org</id>
                               <url>http://repository.jboss.org/maven2</url>
                               <releases>
                                  <enabled>true</enabled>
                               </releases>
                               <snapshots>
                                  <enabled>false</enabled>
                               </snapshots>
                            </repository>
                         </repositories>
                      </profile>



                Now on to the JRebel 3 testing!!!

                • 5. Re: Building the Weld JSF examples
                  Arbi Sookazian Master

                  btw, this is still happening:


                  [INFO] Working directory: C:\java\weld-1.0.1-Final\examples\jsf\numberguess
                  Provider message:
                  The svn command failed.
                  Command output:
                  svn: '.' is not a working copy

                  • 6. Re: Building the Weld JSF examples
                    Pete Muir Master

                    We are working having all deps in Maven central so that this is not an issue in the future.