7 Replies Latest reply on Apr 26, 2007 7:05 PM by Sergey Smirnov

    Do you know why I get this exception all the time?

    vivian hu Novice

      I keep having this error, do you know what is wrong? my files are the following:
      =====================================

      <%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      
      <html>
      <head>
      <title></title>
      </head>
      <body>
      <f:view>
       <table border="1">
       <tr>
       <td><rich:tree style="width:300px" value="#{treeBean.data}" var="item">
       <rich:treeNode type="root">
       <h:outputText value="#{item.type}" />
       </rich:treeNode>
       <rich:treeNode type="child">
       <h:outputText value="#{item.name}" />
       </rich:treeNode>
       </rich:tree></td>
       <td></td>
       </tr>
       </table>
      </f:view>
      </body>
      </html>
      
      public class TreeBean implements TreeNode{
       private static final long serialVersionUID = 6514596192023597908L;
       private Map groups = null;
       public TreeBean() {
       }
      
       public void addChild(Object id, TreeNode group) {
       getGroups().put(id, group);
       }
      
       public TreeNode getChild(Object id) {
       return (TreeNode)getGroups().get(id);
       }
      
       public Iterator getChildren() {
       return getGroups().entrySet().iterator();
       }
      
       public Object getData() {
       return this;
       }
      
       public TreeNode getParent() {
       return null;
       }
      
       public boolean isLeaf() {
       return getGroups().isEmpty();
       }
      
       public void removeChild(Object id) {
       getGroups().remove(id);
       }
      
       public void setData(Object arg0) {
       }
      
       public void setParent(TreeNode arg0) {
       }
      
       public String getType(){
       return "root";
       }
      
       public Map getGroups() {
       if (this.groups==null) {
       initData();
       }
       return this.groups;
       }
      
      
       public void setGroups(Map groups){
       this.groups = groups;
       }
      
       public void addGroup(ChildNodeBean group) {
       addChild(Long.toString(group.getId()), group);
       group.setParent(this);
       }
      
       private void initData() {
       for (int i = 0; i < 100; i++) {
       ChildNodeBean branchNode = new ChildNodeBean(i);
       branchNode.setParent(this);
       branchNode.setName("name" + i);
       addGroup(branchNode);
       }
       }
      }
      
      
      
      

      -------------------------------------------
      javax.faces.FacesException: Resources framework is not initialised, check web.xml for Filter configuration
      org.ajax4jsf.framework.resource.ResourceBuilderImpl.getWebXml(ResourceBuilderImpl.java:107)
      org.ajax4jsf.framework.resource.ResourceBuilderImpl.getUri(ResourceBuilderImpl.java:309)
      org.ajax4jsf.framework.resource.InternetResourceBase.getUri(InternetResourceBase.java:211)
      org.ajax4jsf.framework.resource.BaseResourceRenderer.encodeBegin(BaseResourceRenderer.java:62)
      org.ajax4jsf.framework.resource.OneTimeRenderer.encodeBegin(OneTimeRenderer.java:48)
      org.ajax4jsf.framework.resource.BaseResourceRenderer.encode(BaseResourceRenderer.java:45)
      org.ajax4jsf.framework.resource.InternetResourceBase.encode(InternetResourceBase.java:306)
      org.ajax4jsf.framework.resource.ClientScript.encode(ClientScript.java:143)
      org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase.encodeResourcesArray(HeaderResourcesRendererBase.java:131)
      org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase.preEncodeBegin(HeaderResourcesRendererBase.java:117)
      org.ajax4jsf.framework.renderer.RendererBase.encodeBegin(RendererBase.java:94)
      javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:683)
      javax.faces.component.UIData.encodeBegin(UIData.java:681)
      org.ajax4jsf.ajax.repeat.UIDataAdaptor.encodeBegin(UIDataAdaptor.java:926)
      javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:591)
      javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:543)
      org.apache.jsp.pages.main_jsp._jspx_meth_rich_tree_0(main_jsp.java:153)
      org.apache.jsp.pages.main_jsp._jspx_meth_f_view_0(main_jsp.java:107)
      org.apache.jsp.pages.main_jsp._jspService(main_jsp.java:70

        • 1. Re: Do you know why I get this exception all the time?
          vivian hu Novice

          public class ChildNodeBean implements TreeNode{
          private static final long serialVersionUID = 6614596192023597908L;
          private TreeNode parent;
          private String name;
          private long id;

          public ChildNodeBean(long id) {
          this.id = id;
          }

          public long getId() {
          return id;
          }

          public String getName() {
          return name;
          }

          public void setName(String name) {
          this.name = name;
          }

          public void addChild(Object id, TreeNode group) {
          }

          public TreeNode getChild(Object id) {
          return null;
          }

          public Iterator getChildren() {
          return new ArrayList().iterator();
          }

          public Object getData() {
          return this;
          }

          public TreeNode getParent() {
          return parent;
          }

          public boolean isLeaf() {
          return true;
          }

          public void removeChild(Object id) {
          }

          public void setData(Object arg0) {
          }

          public void setParent(TreeNode parent) {
          this.parent = parent;
          }


          public String getType(){
          return "child";
          }
          }

          • 2. Re: Do you know why I get this exception all the time?
            vivian hu Novice

            here is my web.xml

            <?xml version="1.0"?>
            <web-app version="2.4" 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">
            <display-name>vdi</display-name>
            <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>server</param-value>
            </context-param>

            <context-param>
            <param-name>javax.faces.application.CONFIG_FILES</param-name>
            <param-value>/WEB-INF/faces-config.xml</param-value>
            </context-param>

            <context-param>
            <param-name>com.sun.faces.validateXml</param-name>
            <param-value>true</param-value>
            </context-param>


            <listener-class>com.sun.faces.config.ConfigureListener</listener-class>

            <!-- Faces Servlet -->

            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>

            <!-- Faces Servlet Mapping -->
            <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.jsf</url-pattern>
            </servlet-mapping>
            <login-config>
            <auth-method>BASIC</auth-method>
            </login-config>
            </web-app>

            • 3. Re: Do you know why I get this exception all the time?
              moldovan Newbie

              Define Ajax4jsf Filter (as the first filter in web.xml):

              <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>
               <servlet-name>FacesServlet</servlet-name>
               <dispatcher>REQUEST</dispatcher>
               <dispatcher>FORWARD</dispatcher>
               <dispatcher>INCLUDE</dispatcher>
              </filter-mapping>
              


              • 4. Re: Do you know why I get this exception all the time?
                vivian hu Novice

                I added those line, but it didn't help. still the same error.

                • 5. Re: Do you know why I get this exception all the time?
                  Sergey Smirnov Master

                  post the current version of web.xml. Be sure you deploy the application successfully.

                  • 6. Re: Do you know why I get this exception all the time?
                    vivian hu Novice

                     

                    <?xml version="1.0"?>
                    <web-app version="2.4" 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">
                     <display-name>vdi</display-name>
                     <context-param>
                     <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                     <param-value>server</param-value>
                     </context-param>
                    
                     <context-param>
                     <param-name>javax.faces.application.CONFIG_FILES</param-name>
                     <param-value>/WEB-INF/faces-config.xml</param-value>
                     </context-param>
                    
                     <context-param>
                     <param-name>com.sun.faces.validateXml</param-name>
                     <param-value>true</param-value>
                     </context-param>
                    
                     <listener>
                     <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
                     </listener>
                     <!-- 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>
                     <!-- Faces Servlet Mapping -->
                     <servlet-mapping>
                     <servlet-name>Faces Servlet</servlet-name>
                     <url-pattern>*.jsf</url-pattern>
                     </servlet-mapping>
                    
                     <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>
                     <servlet-name>FacesServlet</servlet-name>
                     <dispatcher>REQUEST</dispatcher>
                     <dispatcher>FORWARD</dispatcher>
                     <dispatcher>INCLUDE</dispatcher>
                     </filter-mapping>
                    
                     <login-config>
                     <auth-method>BASIC</auth-method>
                     </login-config>
                    </web-app>
                    




                    • 7. Re: Do you know why I get this exception all the time?
                      Sergey Smirnov Master

                      Pay attention:
                      You have <servlet-name>FacesServlet</servlet-name> for filter,
                      but <servlet-name>Faces Servlet</servlet-name> for servlet

                      This little space between "Faces" and "Servlet" makes the huge difference.