6 Replies Latest reply on Nov 28, 2006 1:05 PM by ama55

    Error when using ajax and facelets

    ama55

      Dear All:
      i am trying to use faclets and ajax in my project (similar to the hotel booking example), i am using almost the same web.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <web-app version="2.5"
       xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      
       <!-- Ajax4jsf (must come first!) -->
      
       <filter>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>ajax4jsf</filter-name>
       <url-pattern>*.seam</url-pattern>
       </filter-mapping>
      
       <context-param>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
       </context-param>
      


      i have added the following jar files to the project;
      jboss-seam-ui.jar
      ajax4jsf.jar

      but still i am getting the following error:
      java.lang.ClassNotFoundException: org.jboss.seam.ui.facelet.SeamFaceletViewHandler


      any idea how to solve that.
      Thanks in advance

      Best Regards
      ama55

        • 1. Re: Error when using ajax and facelets
          ellenzhao

          can you please paste your build.xml and application.xml here?

          • 2. Re: Error when using ajax and facelets
            ama55

            Here is the build.xml

            <?xml version="1.0"?>
            <project name="Phone Directory" default="deploy" basedir=".">
            <!-- Allow this to be overriden by others importing this project. -->
             <dirname property="imported.basedir" file="${ant.file.Seam}" />
            <!-- Give user a chance to override without editing this file or typing -D -->
             <property file="${imported.basedir}/build.properties" />
            <!-- Name of project and version, used to create filenames -->
             <property name="Name" value="SeamApplication" />
             <property name="name" value="seamapp" />
            <!-- set global properties for this build -->
             <property name="build.dir" value="build" />
             <property name="classes.dir" value="${build.dir}/classes" />
             <property name="src.java.dir" value="src" />
             <property name="lib.dir" value="lib" />
             <property name="deploy.dir" value="${jboss.home}/server/default/deploy" />
             <property name="javac.debug" value="true" />
             <property name="javac.deprecation" value="false" />
            <!-- WAR -->
             <zipfileset id="war.docroot" dir="resources/jsp">
             <include name="**/*" />
             </zipfileset>
             <zipfileset id="war.webinf" prefix="WEB-INF" dir="resources/WEB-INF">
             <patternset refid="meta.files" />
             </zipfileset>
             <zipfileset id="war.webinf.lib" prefix="WEB-INF/lib" dir="resources/WEB-INF/lib">
             <include name="*.jar" />
             </zipfileset>
            <!-- EJB3 -->
             <fileset id="ejb3.root" dir="resources">
             <include name="import.sql" />
             <include name="seam.properties" />
             <include name="META-INF/persistence.xml" />
             </fileset>
             <fileset id="ejb3.lib" dir="lib">
             <include name="jboss-seam.jar" />
             </fileset>
            <!-- EAR -->
             <zipfileset id="ear.resources" prefix="META-INF" dir="resources/META-INF">
             <include name="*" />
             <exclude name="persistence.xml" />
             </zipfileset>
            <!-- Deploy -->
             <fileset id="deploy" dir="resources">
             <include name="_NONE_" />
             </fileset>
            <!-- Undeploy -->
             <patternset id="undeploy">
             <include name="_NONE_" />
             </patternset>
             <path id="build.classpath">
             <fileset dir="${lib.dir}">
             <include name="**/*.jar" />
             </fileset>
             </path>
             <patternset id="meta.files">
             <include name="**/*.dtd" />
             <include name="**/*.xml" />
             <include name="**/*.xslt" />
             <include name="**/*.properties" />
             </patternset>
             <patternset id="src.files">
            <!-- include everything we want in the src directory
             that we didn't want in the jar itself -->
             <include name="**/*.java" />
             </patternset>
             <target name="clean" description="Cleans up the build directory">
             <delete dir="${build.dir}" />
             </target>
             <target name="init" description="Initialize the build">
             <echo message="Build ${Name}" />
             <mkdir dir="${classes.dir}" />
             <copy todir="${classes.dir}">
             <fileset dir="${src.java.dir}">
             <patternset refid="meta.files" />
             </fileset>
             </copy>
             </target>
             <target name="compile" depends="init" description="Compile the Java source code">
             <javac destdir="${classes.dir}" classpathref="build.classpath" debug="${javac.debug}" deprecation="${javac.deprecation}" nowarn="on">
             <src path="${src.java.dir}" />
             </javac>
             </target>
             <target name="war" depends="compile">
             <jar destfile="${build.dir}/${name}.war">
             <zipfileset refid="war.docroot" />
             <zipfileset refid="war.webinf" />
             <zipfileset refid="war.webinf.lib" />
             </jar>
             </target>
             <target name="ejb3" depends="compile">
             <jar jarfile="${build.dir}/${name}.ejb3">
             <fileset dir="${imported.basedir}">
             <include name="${name}.jar" />
             </fileset>
             <fileset dir="${classes.dir}">
             <include name="**/*.class" />
             <exclude name="**/test/*.class" />
             </fileset>
             <fileset refid="ejb3.root" />
             <fileset refid="ejb3.lib" />
             </jar>
             </target>
             <target name="ear" depends="ejb3, war">
             <jar destfile="${build.dir}/${name}.ear">
             <zipfileset dir="${build.dir}">
             <include name="${name}.ejb3" />
             </zipfileset>
             <zipfileset dir="${build.dir}">
             <include name="${name}.war" />
             </zipfileset>
             <zipfileset refid="ear.resources" />
             </jar>
             </target>
             <target name="deploy" depends="ear">
             <property name="unit.ext" value="ear" />
             <fail unless="jboss.home">jboss.home MUST be set. Update build.properties to point to a valid JBoss installation.</fail>
             <copy todir="${deploy.dir}">
             <fileset refid="deploy" />
             </copy>
             <copy file="${build.dir}/${name}.${unit.ext}" todir="${deploy.dir}" />
             </target>
             <target name="undeploy">
             <property name="unit.ext" value="ear" />
             <delete file="${deploy.dir}/${name}.${unit.ext}" />
             <delete>
             <fileset dir="${deploy.dir}">
             <patternset refid="undeploy" />
             </fileset>
             </delete>
             </target>
             <target name="cleandb">
             <delete dir="${deploy.dir}/../data/hypersonic" />
             </target>
            </project>
            


            and here is the application.xml file:
            <?xml version="1.0" encoding="utf-8"?>
            <application>
             <display-name>SeamApplication</display-name>
             <module>
             <web>
             <web-uri>seamapp.war</web-uri>
             <context-root>/seamapp</context-root>
             </web>
             </module>
             <module>
             <ejb>seamapp.ejb3</ejb>
             </module>
            </application>
            


            Best Regards
            ama55

            • 3. Re: Error when using ajax and facelets

              These are the mods i did in my web.xml to have Ajax4JSf working

              
              
              <!-- Ajax4jsf -->
               <filter>
               <display-name>Ajax4jsf Filter</display-name>
               <filter-name>ajax4jsf</filter-name>
               <filter-class>org.ajax4jsf.Filter</filter-class>
               </filter>
               <filter-mapping>
               <filter-name>ajax4jsf</filter-name>
               <url-pattern>*.seam</url-pattern>
               </filter-mapping>
              
              
               <context-param>
               <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
               <param-value>com.sun.facelets.FaceletViewHandler</param-value>
               </context-param>
              
              
               <filter-mapping>
               <filter-name>Seam Exception Filter</filter-name>
               <url-pattern>/*</url-pattern>
               </filter-mapping>
              
               <filter-mapping>
               <filter-name>Seam Redirect Filter</filter-name>
               <url-pattern>*.seam</url-pattern>
               </filter-mapping>
              
              


              You also need to have the oscache-2.3.2 and ajax4jsf jars to have ajax working

              • 4. Re: Error when using ajax and facelets
                ellenzhao

                Since there is

                <fileset id="ejb3.lib" dir="lib">
                 <include name="jboss-seam.jar" />
                 </fileset>
                in the <!--- EJB3 ---> section in your build.xml, I suppose there would be something like
                <module>
                 <java>jboss-seam.jar</java>
                 </module>

                in the application.xml. Now the question is: Is the jboss-seam.jar found by your application server when the application was deployed? If not, try to add the code list above to your application.xml.

                • 5. Re: Error when using ajax and facelets
                  ellenzhao

                  Ah sorry i made a mistake. That was "EJB3" section but not "EAR" section. So I guess the jboss-seam.jar may well be already be found at deploy time.

                  I modified the hotel booking example too and the packaging strategy also followed the example (your packaging is a bit different). Everything including ajax4jsf worked fine.

                  Here is my latest packaging-build.xml (it can be easily mapped to build.xml)

                  <?xml version="1.0" encoding="UTF-8"?>
                  <project name="Packaging Generator" default="_packaging_generation_">
                   <target name="_packaging_generation_" depends="N65540,N65605,N65722" />
                   <target name="N65540" description="hotelEJB.jar">
                   <mkdir dir="dist" />
                   <jar destfile="dist/hotelEJB.jar">
                   <zipfileset dir="resources/META-INF" prefix="META-INF">
                   <include name="ejb-jar.xml" />
                   </zipfileset>
                   <zipfileset dir="resources/META-INF" prefix="META-INF">
                   <include name="persistence.xml" />
                   </zipfileset>
                   <zipfileset dir="resources">
                   <include name="jndi.properties" />
                   </zipfileset>
                   <zipfileset dir="resources">
                   <include name="seam.properties" />
                   </zipfileset>
                   <zipfileset dir="resources">
                   <include name="testdb-ds.xml" />
                   </zipfileset>
                   <zipfileset dir="resources">
                   <include name="hotel-ds.xml" />
                   </zipfileset>
                   <zipfileset dir="bin" />
                   </jar>
                   </target>
                   <target name="N65605" description="hotelWeb.war">
                   <mkdir dir="dist" />
                   <jar destfile="dist/hotelWeb.war">
                   <zipfileset dir="D:\sd\lib\jboss-seam-1.1.0.BETA2" prefix="WEB-INF/lib">
                   <include name="jboss-seam-debug.jar" />
                   </zipfileset>
                   <zipfileset dir="D:\sd\lib\jboss-seam-1.1.0.BETA2" prefix="WEB-INF/lib">
                   <include name="jboss-seam-ui.jar" />
                   </zipfileset>
                   <zipfileset dir="D:\sd\lib\facelets-1.1.11" prefix="WEB-INF/lib">
                   <include name="jsf-facelets.jar" />
                   </zipfileset>
                   <zipfileset dir="D:\sd\lib\facelets-1.1.11\lib" prefix="WEB-INF/lib">
                   <include name="el-api.jar" />
                   </zipfileset>
                   <zipfileset dir="D:\sd\lib\facelets-1.1.11\lib" prefix="WEB-INF/lib">
                   <include name="el-ri.jar" />
                   </zipfileset>
                   <zipfileset dir="resources/WEB-INF" prefix="WEB-INF">
                   <include name="components.xml" />
                   </zipfileset>
                   <zipfileset dir="resources/WEB-INF" prefix="WEB-INF">
                   <include name="faces-config.xml" />
                   </zipfileset>
                   <zipfileset dir="resources/WEB-INF" prefix="WEB-INF">
                   <include name="navigation.xml" />
                   </zipfileset>
                   <zipfileset dir="resources/WEB-INF" prefix="WEB-INF">
                   <include name="web.xml" />
                   </zipfileset>
                   <zipfileset dir="resources">
                   <include name="pageflow.jpdl.xml" />
                   </zipfileset>
                   <zipfileset dir="D:\sd\lib\ajax4jsf-1.0.3-full.zip_FILES\lib" prefix="WEB-INF/lib">
                   <include name="ajax4jsf.jar" />
                   </zipfileset>
                   <zipfileset dir="D:\sd\lib\ajax4jsf-1.0.3-full.zip_FILES\lib" prefix="WEB-INF/lib">
                   <include name="oscache-2.3.2.jar" />
                   </zipfileset>
                   <zipfileset dir="view" />
                   </jar>
                   </target>
                   <target name="N65722" description="hotel.ear">
                   <mkdir dir="dist" />
                   <jar destfile="dist/hotel.ear">
                   <zipfileset dir="resources/META-INF" prefix="META-INF">
                   <include name="application.xml" />
                   </zipfileset>
                   <zipfileset dir="resources/META-INF" prefix="META-INF">
                   <include name="jboss-app.xml" />
                   </zipfileset>
                   <zipfileset dir="D:\sd\lib\jboss-seam-1.1.0.BETA2">
                   <include name="jboss-seam.jar" />
                   </zipfileset>
                   <zipfileset dir="D:\sd\lib\jbpm-bpel-1.1.Beta2\lib\jbpm">
                   <include name="jbpm-3.1.2.jar" />
                   </zipfileset>
                   <zipfileset dir="dist">
                   <include name="hotelEJB.jar" />
                   </zipfileset>
                   <zipfileset dir="dist">
                   <include name="hotelWeb.war" />
                   </zipfileset>
                   </jar>
                   </target>
                  </project>
                  
                  


                  • 6. Re: Error when using ajax and facelets
                    ama55

                    That made it working for now
                    thanks for your help

                    Best Regards
                    ama55