5 Replies Latest reply: May 6, 2012 1:53 PM by Paul Dijou RSS

javax.servlet.ServletException: Función "rich:component" not found

Black Red Newbie

Hello boys!

 

First I want to say it is a pleasure to start a part of this community and I hope graduallyto bring more of what I bring to my and, very important, sorry for my english xD

 

Well, my error it's obvious, I can't do anything with richfaces. I put one example of richfaces live demo but nothing, I want put a rich:popupPanel but only see plane text where must see the panel with the text of course.

 

I use richfaces richfaces 4.2.1 (the four librarys), Javax.faces 2.1.7, maven how archetype project (although my librarys richfaces and jsf I put it in build path manually) and hibernate for mapping DataBase. All it's ok less richfaces.

 

I read in the net many things about it, but nothing "clear", the jars I can't put in the web-if/lib because else tomcat not work, and I read too the make a managed bean that replace the class "rich:component" but i don't know good...

 

In my web.xml:

 


<?xml version="1.0"?>
<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">
          <display-name>Archetype Created Web Application</display-name>

  <!-- JSF -->
  <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>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
</web-app>

 

In faces-config.xml I have put something? only I read

 

<?xml version="1.0" encoding="UTF-8"?>

<faces-config 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-facesconfig_2_1.xsd"
  version="2.1">


....

managed bean and navegation-rules



</faces-config>


 

My xhtml it's simple of richfaces live demo

 

 

<!DOCTYPE html 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:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:rich="http://richfaces.org/rich">
  <h:commandButton value="Call the popup">
  <rich:componentControl target="popup" operation="show" />
  </h:commandButton>
  <rich:popupPanel id="popup" modal="true" resizeable="true"
  onmaskclick="#{rich:component('popup')}.hide()">
  <f:facet name="header">
  <h:outputText value="Simple popup panel" />
  </f:facet>
  <f:facet name="controls">
  <h:outputLink value="#"
  onclick="#{rich:component('popup')}.hide(); return false;">
                X
            </h:outputLink>
  </f:facet>
                    <p>You can also check and trigger events if the use clicks outside
                              of the panel.</p>

                    <p>In this example clicking outside closes the panel.</p>
  </rich:popupPanel>
</ui:composition>

 

Very very thanks in advance. I hope you can help me.

 

Regards

  • 1. Re: javax.servlet.ServletException: Función "rich:component" not found
    Paul Dijou Newbie

    Hi there,

     

    I think your XHTML page can't be only that piece of code. Otherwise, there is no head tag on your html page. When you see a demo code wrapped in a "<ui:composition>" tag, it means that it only show you the demo code but in reality, this code is include in a more complex code in order to render the full page.

    <!DOCTYPE html>

     

    <html lang="en-US"

          xmlns="http://www.w3.org/1999/xhtml"

          xmlns:h="http://java.sun.com/jsf/html"

          xmlns:f="http://java.sun.com/jsf/core"

          xmlns:ui="http://java.sun.com/jsf/facelets"

          xmlns:rich="http://richfaces.org/rich"

          xmlns:a4j="http://richfaces.org/a4j">

    <h:head>

        <title>Page title</title>

    </h:head>

    <h:body>

      <h:commandButton value="Call the popup">

      <rich:componentControl target="popup" operation="show" />

      </h:commandButton>

      <rich:popupPanel id="popup" modal="true" resizeable="true"

      onmaskclick="#{rich:component('popup')}.hide()">

      <f:facet name="header">

      <h:outputText value="Simple popup panel" />

      </f:facet>

      <f:facet name="controls">

      <h:outputLink value="#"

      onclick="#{rich:component('popup')}.hide(); return false;">

                    X

                </h:outputLink>

      </f:facet>

                        <p>You can also check and trigger events if the use clicks outside

                                  of the panel.</p>

     

                        <p>In this example clicking outside closes the panel.</p>

      </rich:popupPanel>

    </h:body>

    </html>

     

    Here is a really simple template in order to wrap your code.

     

    I don't understand why Tomcat would complain about having JSF and RichFaces jars in the WEB-INF/lib/ dir if your package is a WAR. You will need to check if the jars are really on you packaged WAR before deploying on Tomcat. If you only have them on your buildpath but don't package them on your WAR, they will be missing when you deploy your application.

  • 2. Re: javax.servlet.ServletException: Función "rich:component" not found
    Black Red Newbie

    Thank you for you reply, I put the tag, html, head, how you wrote me, (seemed strange that I had not it) haha, but, not work.

     

    About the jars in lib... I don't know... but is my First project with maven and richfaces, maybe was it... because before, I did all projects and I put the jars in lib without problems... in my pom.xml my package is war... but if I not put the jars in library all is ok, but the first problem with richfaces... :S

     

    What do I do?

     

    my web.xml is ok for richfaces not? and in my faces-config... have I put something? and in other place?

     

    My pom.xml is this... but the jsf and richfaces jars I put in builth path manually ok?

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

      <modelVersion>4.0.0</modelVersion>

      <groupId>com.lintips</groupId>

      <artifactId>mavenwebapp</artifactId>

      <packaging>war</packaging>

              <version>0.0.1-SNAPSHOT</version>

              <name>mavenwebapp Maven Webapp</name>

              <url>http://maven.apache.org</url>

      <dependencies>

      <dependency>

      <groupId>junit</groupId>

      <artifactId>junit</artifactId>

      <version>3.8.1</version>

      <scope>test</scope>

      </dependency>

      <dependency>

                                  <groupId>org.hibernate</groupId>

                                  <artifactId>hibernate-entitymanager</artifactId>

                                  <version>4.1.1.Final</version>

      </dependency>

     

      <dependency>

      <groupId>mysql </groupId>

                                  <artifactId>mysql-connector-java</artifactId>

      <version>5.1.6</version>

                                  <scope>compile</scope>

      </dependency>

     

      <dependency>

                                  <groupId>javax.servlet</groupId>

      <artifactId>jstl</artifactId>

      <version>1.2</version>

      </dependency>

     

      <dependency>

                                  <groupId>javax.servlet</groupId>

      <artifactId>servlet-api</artifactId>

      <version>2.5</version>

      </dependency>

     

      <dependency>

                                  <groupId>org.apache.maven.plugins</groupId>

                                  <artifactId>maven-dependency-plugin</artifactId>

      <version>2.4</version>

      </dependency>

      </dependencies>

      <build>

      <finalName>mavenwebapp</finalName>

      </build>

    </project>

     

    http://img690.imageshack.us/img690/1069/capturadepantalla201205h.png

  • 3. Re: javax.servlet.ServletException: Función "rich:component" not found
    Paul Dijou Newbie

    What about adding the dependencies to your pom.xml instead of adding them manually?

     

            <dependency>
                <groupId>com.sun.faces</groupId>
                <artifactId>jsf-impl</artifactId>
                <version>2.1.7</version>
            </dependency>
                <groupId>org.richfaces.ui</groupId>
                <artifactId>richfaces-components-ui</artifactId>
                <version>4.2.1.Final</version>
            </dependency>
            <dependency>
                <groupId>org.richfaces.core</groupId>
                <artifactId>richfaces-core-impl</artifactId>
                <version>4.2.1.Final</version>
            </dependency>
    

     

     

    Here is a sample of a pom.xml for a project using RichFaces : https://github.com/richfaces/sandbox/blob/develop/bootstrap/demo/pom.xml

     

    RichFaces doesn't even need a web.xml by default, and your looks fine.

  • 4. Re: javax.servlet.ServletException: Función "rich:component" not found
    Black Red Newbie

    ohhh hahahaha, very thanks, it's work ok, very very thanks... I am stupid... I thought that if I put in build path did not have to put it in the pom.xml and, before than I put the pom.xml here I only had one dependency of richfaces... I thought that automatically download all dependencys... so, only put one, core or ui... that is the mistake...

     

    Very thanks adain...

     

    Regards

  • 5. Re: javax.servlet.ServletException: Función "rich:component" not found
    Paul Dijou Newbie

    My pleasure. Have fun with RichFaces