Iniciando em JSF

3 respostas
J

Estou começando agora no jsf e já estou tendo problemas…hehhehe
O problema é o seguinte, não conigo inicializar a aplicação no manager do tomcat.
Abaixo segue os arquivos web.xml e faces-config.xml:

web.xml

<?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/webapp_2_5.xsd">
        <description>
                Aplicacao para testar o JSF
        </description>
        <display-name>Teste JSF</display-name>
        <context-param>
                <param-name>com.sun.faces.verifyObjects</param-name>
                <param-value>true</param-value>
        </context-param>
        <context-param>
                <param-name>com.sun.faces.validateXml</param-name>
                <param-value>true</param-value>
        </context-param>
        <context-param>
                <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                <param-value>client</param-value>
        </context-param>
        <context-param>
                <param-name>javax.faces.CONFIG_FILES</param-name>
                <param-value>/WEB-INF/faces-config.xml</param-value>
        </context-param>
        <listener>
                <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
        </listener>
        <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>/faces/*</url-pattern>
                <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>
        <welcome-file-list>
                <welcome-file>/WEB-INF/index.jsp</welcome-file>
        </welcome-file-list> 

</web-app>

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="1.2" 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 ht
tp://java.sun.com/xml/ns/javaee/webfacesconfig_1_2.xsd">
        <managed-bean>
                <managed-bean-name>hwBean</managed-bean-name>
                <managed-bean-class>jsfExample.HelloWorldBean</managed-bean-clas>
                <managed-bean-scope>request</managed-bean-scope>

        </managed-bean>
        <navigation-rule>
                <navigation-case>
                        <from-outcome>Sucess</from-outcome>
                        <to-view-id>/resultado.jsp</to-view-id>
                </navigation-case>
        </navigation-rule>
</faces-config>

No web.xml quando eu tiro as linhas abaixo a apilcação inicializa, mas não consigo abrir a página index.jsp.

<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>/faces/*</url-pattern>
                <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>

Desde já agradeço a ajuda de todos.

3 Respostas

E
<?xml version="1.0" encoding="UTF-8"?> LivrariaJSF index.jsp Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet /faces/*

vê se ajuda aí !

J

Coloquei o web.xml igual ao seu e nada ainda.
Fui no catalina.out e está dando este erro:

Mar 19, 2008 7:49:35 PM org.apache.catalina.core.StandardContext stop
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Demo] has not been started
Mar 19, 2008 7:49:35 PM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.
Mar 19, 2008 7:49:35 PM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.
Mar 19, 2008 7:49:35 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra (1.2_08-b06-FCS) for context '/Demo'
Mar 19, 2008 7:49:35 PM com.sun.faces.config.ConfigureListener contextInitialized
WARNING: JSF1059: WARNING!  The com.sun.faces.verifyObjects feature is to aid developers not using tools.  It shouldn''t be enabled if using an IDE, or if this application is being
 deployed for production as it will impact application start times.
Mar 19, 2008 7:49:36 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 19, 2008 7:49:36 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Demo] startup failed due to previous errors
Mar 19, 2008 7:49:44 PM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.
Mar 19, 2008 7:49:44 PM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.
Mar 19, 2008 7:49:44 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra (1.2_08-b06-FCS) for context '/Demo'
Mar 19, 2008 7:49:44 PM com.sun.faces.config.ConfigureListener contextInitialized
WARNING: JSF1059: WARNING!  The com.sun.faces.verifyObjects feature is to aid developers not using tools.  It shouldn''t be enabled if using an IDE, or if this application is being
 deployed for production as it will impact application start times.
Mar 19, 2008 7:49:46 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 19, 2008 7:49:46 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Demo] startup failed due to previous errors
J

Achei o erro, era no faces-config.xml na tag managed-bean-class, na tag que era para fechar estava assim managed-bean-clas (sem um “s”).
Agora apareceu outro erro:
http - 500

org.apache.jasper.JasperException: java.lang.RuntimeException: Cannot find FacesContext
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Criado 19 de março de 2008
Ultima resposta 20 de mar. de 2008
Respostas 3
Participantes 2