3 Replies Latest reply on Mar 2, 2007 3:12 PM by Dustin Norlander

    Setting up an ajax4jsf + trinidad project

    Dustin Norlander Apprentice

      I am trying to set up a new project using ajax4jsf+trinidad and having problems. I have followed this doc: http://wiki.apache.org/myfaces/TrinidadSeamAjax4JsfFaceletDetail


      I am getting this error:

      17:12:13,846 INFO [StartupServletContextListener] Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
      17:12:13,878 ERROR [STDERR] Mar 1, 2007 5:12:13 PM org.apache.myfaces.trinidad.webapp.TrinidadFilter init
      SEVERE: null
      java.lang.ClassNotFoundException: org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl
       at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1355)
       at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
       at org.apache.myfaces.trinidad.webapp.TrinidadFilter.init(TrinidadFilter.java:52)
       at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:223)
       at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:304)
       at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:77)
      



      I added the trinidad and a4j-trinidad jar to WEB-INF/lib (and added them to the build.xml to be added to the ear) -- Is that right???

      this is my web.xml:
      <?xml version="1.0" ?>
      <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
       version="2.4">
      
       <!-- Ajax4jsf (must come first!) -->
       <!-- ************************ AJAX4JSF Filter **************************** -->
       <!-- If you have other filters declared in the web.xml, be sure that Ajax4jsf Filter is declared before the others. -->
       <filter>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       <init-param>
       <param-name>forceparser</param-name>
       <param-value>false</param-value>
       </init-param>
       </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>
      
       <!-- ************************ Trinidad Filter **************************** -->
       <filter>
       <filter-name>Trinidad</filter-name>
       <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>Trinidad</filter-name>
       <!--<servlet-name>Faces Servlet</servlet-name>-->
       <url-pattern>*.seam</url-pattern>
       </filter-mapping>
      
      
       <!-- Seam -->
      
       <listener>
       <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
       </listener>
      
       <filter>
       <filter-name>Seam Filter</filter-name>
       <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>Seam Filter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
      
       <servlet>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/seam/resource/*</url-pattern>
       </servlet-mapping>
      
       <!-- MyFaces -->
      
       <listener>
       <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
       </listener>
      
       <!-- Facelets development mode (disable in production) -->
      
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <!-- JSF -->
      
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>client</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.seam</url-pattern>
       </servlet-mapping>
      
      
       <!-- ************************ Trinidad resources servlet **************************** -->
       <servlet>
       <servlet-name>Trinidad Resources</servlet-name>
       <servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>
       </servlet>
      
       <!-- This cannot be configured currently -->
       <servlet-mapping>
       <servlet-name>Trinidad Resources</servlet-name>
       <url-pattern>/adf/*</url-pattern>
       </servlet-mapping>
      
       <security-constraint>
       <display-name>Restrict raw XHTML Documents</display-name>
       <web-resource-collection>
       <web-resource-name>XHTML</web-resource-name>
       <url-pattern>*.xhtml</url-pattern>
       </web-resource-collection>
       <auth-constraint>
       <role-name>NONE</role-name>
       </auth-constraint>
       </security-constraint>
      
      </web-app>
      


        • 1. Re: Setting up an ajax4jsf + trinidad project
          Pierre Raoul Novice

          Hello,

          added the trinidad and a4j-trinidad jar


          Can you be more specefic? trinidad-api-incubator-m1-SNAPSHOT.jar and trinidad-impl-incubator-m1-SNAPSHOT.jar?

          to WEB-INF/lib and added them to the build.xml to be added to the ear


          are they copied in the root of the project ear or in the WEB-INF/lib of the project war?

          About the config files, mines are below.

          Regards
          Pierre

          <?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 before the other filters!) -->
          
          <!--
           <context-param>
           <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
           <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
           </context-param>
          -->
          
           <filter>
           <display-name>Ajax4jsf Filter</display-name>
           <filter-name>ajax4jsf</filter-name>
           <filter-class>org.ajax4jsf.Filter</filter-class>
           <init-param>
           <param-name>forceparser</param-name>
           <param-value>false</param-value>
           </init-param>
           </filter>
          
           <filter-mapping>
           <filter-name>ajax4jsf</filter-name>
           <url-pattern>*.seam</url-pattern>
           </filter-mapping>
          
           <!-- Trinidad -->
          
           <context-param>
           <param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name>
          <!--
           <param-value>com.sun.facelets.FaceletViewHandler</param-value>
          -->
           <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
           </context-param>
          
           <context-param>
           <param-name>org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE</param-name>
           <param-value>false</param-value>
           </context-param>
          
           <context-param>
           <param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name>
           <param-value>true</param-value>
           </context-param>
          
           <filter>
           <filter-name>trinidad</filter-name>
           <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
           </filter>
          
           <filter-mapping>
           <filter-name>trinidad</filter-name>
           <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
           <servlet-name>Faces Servlet</servlet-name>
           <dispatcher>REQUEST</dispatcher>
           <dispatcher>FORWARD</dispatcher>
           <dispatcher>INCLUDE</dispatcher>
           </filter-mapping>
          
           <!-- resource loader servlet -->
           <servlet>
           <servlet-name>resources</servlet-name>
           <servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>
           </servlet>
          
           <servlet-mapping>
           <servlet-name>resources</servlet-name>
           <url-pattern>/adf/*</url-pattern>
           </servlet-mapping>
          
           <!-- Seam -->
          
           <listener>
           <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
           </listener>
          
           <filter>
           <filter-name>Seam Exception Filter</filter-name>
           <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
           </filter>
          
           <filter-mapping>
           <filter-name>Seam Exception Filter</filter-name>
           <url-pattern>/*</url-pattern>
           </filter-mapping>
          
           <!-- Propagate conversations through redirects -->
          
           <filter>
           <filter-name>Seam Redirect Filter</filter-name>
           <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
           </filter>
          
           <filter-mapping>
           <filter-name>Seam Redirect Filter</filter-name>
           <url-pattern>*.seam</url-pattern>
           </filter-mapping>
          
           <!-- Faces servlet -->
          
           <servlet>
           <servlet-name>Faces Servlet</servlet-name>
           <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
           <load-on-startup>1</load-on-startup>
           </servlet>
          
           <servlet-mapping>
           <servlet-name>Faces Servlet</servlet-name>
           <url-pattern>*.seam</url-pattern>
           </servlet-mapping>
          
           <!-- MyFaces -->
          
           <listener>
           <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
           </listener>
          
          [...]
          
          </web-app>
          


          and I have in faces-config.xml
           <application>
           <!-- No FaceletViewHandler in this file
           <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
           <view-handler>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</view-handler>
           -->
           <!-- Use the Trinidad RenderKit AND the ajax4jsf view handler -->
           <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
           <view-handler>org.ajax4jsf.framework.ajax.AjaxViewHandler</view-handler>
           </application>
          
           <!-- Seam transaction management -->
          
           <lifecycle>
           <phase-listener>org.jboss.seam.jsf.TransactionalSeamPhaseListener</phase-listener>
           </lifecycle>
          




          • 2. Re: Setting up an ajax4jsf + trinidad project
            Thomas Hamacher Novice

            Be careful, which version of Seam you are using: The one atao is using is for Seam 1.1.6 whereas dustismo´s is for 1.2.0.

            But as far as I can see from the exception you simply did not include the trinidad-jars properly. Check if you´ve got both jars, the "impl" and the "api" and also include them in your manifest.mf of your jar.

            Thomas

            • 3. Re: Setting up an ajax4jsf + trinidad project
              Dustin Norlander Apprentice

              You were right, I didn't have the impl jar in there. So now everything starts with no exceptions but I'm not sure its working.

              I set up the project using seam-gen (so I assume the jars are automatically added to the jar manifest by the build script).

              <target name="ear" description="Build the EAR">
               <copy todir="${ear.dir}">
               <fileset dir="${basedir}/resources">
               <include name="*jpdl.xml" />
               <include name="hibernate.cfg.xml" />
               <include name="jbpm.cfg.xml" />
               <include name="security.drl" />
               </fileset>
               <fileset dir="${lib.dir}">
               <include name="jboss-seam.jar" />
               <include name="jbpm*.jar" />
               <include name="el-*.jar" />
               <include name="drools-*.jar"/>
               <include name="janino-*.jar"/>
               <include name="antlr-*.jar"/>
               <include name="commons-jci-*.jar"/>
               <include name="stringtemplate-*.jar"/>
               </fileset>
               <!-- Added for trinidad -->
               <fileset dir="${basedir}/resources/WEB-INF/lib">
               <include name="*.jar" />
               </fileset>
               </copy>
               <copy todir="${ear.dir}/META-INF">
               <fileset dir="${basedir}/resources/META-INF">
               <include name="application.xml" />
               <include name="jboss-app.xml" />
               </fileset>
               </copy>
               </target>


              I have never used trinidad before so I am just trying to see if it is configured properly..

              I add this xhtml page

              <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:tr="http://myfaces.apache.org/"
               template="layout/template.xhtml">
              
              <ui:define name="body">
              
               <tr:document title="NavigationModel Demo" maximized="true">
               <tr:form>
               <tr:panelPage>
               <f:facet name="branding">
               <tr:panelGroup layout="horizontal">
               <tr:objectIcon name="logo"/>
               <tr:outputText value="NavigationModel Demo"/>
               </tr:panelGroup>
               </f:facet>
               </tr:panelPage>
               </tr:form>
               </tr:document>
              </ui:define>
              </ui:composition>
              


              which just renders the <tr:> elements directly into the html.