简体   繁体   中英

JSF + RichFaces gives me an HTTP Status 404 in my pages

probably this is a lack of attention issue, if so, forgive me, but I can't see what I'm doing wrong, it took me all the afternoon, I need you help.

I'm doing a JSF + JPA + RichFaces app, it's pretty simple. I did the JPA project, tested, then the JSF project, tested, everything is working fine, but then when I pasted the RichFaces jars in the WEB-INF/lib folder, even before I did any change, the pages that were working stopped, and now I get a HTTP Status 404 page, like if I'm typing the wrong address, but I'm using the same address than before.

Here's my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Monaco</display-name>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
</context-param>

<context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>blueSky</param-value>
</context-param>

<context-param>
    <param-name>org.richfaces.CONTROL_SKINNING</param-name>
    <param-value>enable</param-value>
</context-param>

<filter> 
    <display-name>RichFaces Filter</display-name> 
    <filter-name>richfaces</filter-name> 
    <filter-class>org.ajax4jsf.Filter</filter-class> 
</filter> 

<filter-mapping> 
    <filter-name>richfaces</filter-name> 
    <servlet-name>Faces Servlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>

<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>
</servlet-mapping>
</web-app>

And my faces-config.xml

<?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_1_2.xsd"
version="1.2">

<managed-bean>
    <managed-bean-name>pessoa</managed-bean-name>
    <managed-bean-class>cadastro.Pessoa</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

<managed-bean>
    <managed-bean-name>service</managed-bean-name>
    <managed-bean-class>cadastro.PessoaService</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

<navigation-rule>
    <display-name>inserir.jsf</display-name>
    <from-view-id>/cadastro/pessoa/inserir.jsp</from-view-id>
    <navigation-case>
        <from-outcome>sucesso</from-outcome>
        <to-view-id>/cadastro/pessoa/listar.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
        <from-outcome>erro</from-outcome>
        <to-view-id>/cadastro/pessoa/erro.jsp</to-view-id>
    </navigation-case>
</navigation-rule>

<navigation-rule>
    <display-name>listar.jsf</display-name>
    <from-view-id>/cadastro/pessoa/listar.jsp</from-view-id>
    <navigation-case>
    <from-outcome>voltar</from-outcome>
    <to-view-id>/cadastro/pessoa/inserir.jsp</to-view-id>
    <redirect/>
    </navigation-case>
        <navigation-case>
        <from-outcome>sucesso</from-outcome>
        <to-view-id>/cadastro/pessoa/listar.jsp</to-view-id>
        <redirect/>
    </navigation-case>
    <navigation-case>
        <from-outcome>erro</from-outcome>
        <to-view-id>/cadastro/pessoa/erro.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
        <from-outcome>editar</from-outcome>
        <to-view-id>/cadastro/pessoa/inserir.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
        <from-outcome>editar</from-outcome>
        <to-view-id>/cadastro/pessoa/inserir.jsp</to-view-id>
    </navigation-case>
</navigation-rule>

<navigation-rule>
    <display-name>erro.jsf</display-name>
    <from-view-id>/cadastro/pessoa/erro.jsp</from-view-id>
    <navigation-case>
        <from-outcome>voltar</from-outcome>
        <to-view-id>/cadastro/pessoa/listar.jsp</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>
</faces-config>

I think my JPA project doesn't have relationship with this error, since it's a separeted project and is working fine.

My folder structure is something like

Monaco/
    WebContent/
        cadastro/
            pessoa/
                erro.jsp
                inserir.jsp
                listar.jsp
                test.jsp
        WEB-INF/
            lib/
                richfaces-api-3.3.2.SR1.jar
                richfaces-impl-3.3.2.SR1.jar
                richfaces-ui-3.3.2.SR1.jar
            faces-config.xml
            web.xml
        index.jsp

The url http://localhost:8080/Monaco/faces/cadastro/pessoa/listar.jsp used to work before the RichFaces jars, but now I got:

HTTP Status 404 - /Monaco/faces/cadastro/pessoa/listar.jsp
--------------------------------------------------------------------------------
type Status report
message /Monaco/faces/cadastro/pessoa/listar.jsp
description The requested resource (/Monaco/faces/cadastro/pessoa/listar.jsp) is not available.
--------------------------------------------------------------------------------
JBoss Web/2.1.2.GA

I tried a lot of variants of urls, like:

In all of these I receive the same error (what should be OK), but I can't understand why it stopped only because I've add the RichFaces jars...

Thankz guyz!

Some appserver logs:

16:43:28,879 ERROR [[/Monaco]] Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
javax.faces.FacesException: org.ajax4jsf.renderkit.ChameleonRenderKitFactory
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:556)
    at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:448)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:249)
    at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:1036)
    at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:493)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:381)
    at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:69)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
    at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
    at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
    at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
    at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
    at org.jboss.web.WebModule.startModule(WebModule.java:83)
    at org.jboss.web.WebModule.startService(WebModule.java:61)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy44.start(Unknown Source)
    at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
    at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
    at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
    at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
    at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy45.start(Unknown Source)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy9.deploy(Unknown Source)
    at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
    at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
    at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
    at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy4.start(Unknown Source)
    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy5.deploy(Unknown Source)
    at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    at org.jboss.Main.boot(Main.java:200)
    at org.jboss.Main$1.run(Main.java:508)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:549)
    ... 141 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
    at org.ajax4jsf.resource.ResourceBuilderImpl.registerConfig(ResourceBuilderImpl.java:169)
    at org.ajax4jsf.resource.ResourceBuilderImpl.registerResources(ResourceBuilderImpl.java:153)
    at org.ajax4jsf.resource.ResourceBuilderImpl.init(ResourceBuilderImpl.java:224)
    at org.ajax4jsf.renderkit.ChameleonRenderKitFactory.(ChameleonRenderKitFactory.java:62)
    ... 146 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.digester.Digester
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 150 more
16:43:28,879 ERROR [StandardContext] Error listenerStart
16:43:28,879 ERROR [StandardContext] Context [/Monaco] startup failed due to previous errors

See ya.

You need to put the webcontent files in a /faces root folder, exactly the path as it is in the URL.

Another way is to replace the url-pattern of /faces/* by *.jsf so that you can invoke them without the /faces path, for example: http://localhost:8080/Monaco/cadastro/pessoa/listar.jsf . By the way, you do not need to rename the actual .jsp files to .jsf .

If you want to prevent direct access to the JSP files (otherwise one would be able to request the .jsp file and face a RuntimeException: FacesContext not found ), then you can best move the files (including folder structure) into the WEB-INF folder.

Hope this helps.

Edit: you added the appserver logs. The root cause of the first problem is the following:

java.lang.ClassNotFoundException: org.apache.commons.digester.Digester

This is fairly self-explaining: the mentioned class is missing in the runtime classpath. As the package name already hints it is Apache Commons Digester which you can get at http://commons.apache.org/digester . Put it in the runtime classpath ( WEB-INF/lib ) and restart. See if the subsequent errors will disapear or not (may be indirectly caused by the same problem). If not, come back and edit the stacktrace in your question (don't forget to select it and press the code button (0101011010) or press the Ctrl + K ).

Looking in the logs of JBoss I realized that there where some apache classes missing that RichFaces depends to work (Apache Digester and BeanUtils), so it stopped serving my pages, it was not the urls that were wrong, but that startup errors, well, since I did line by line, step by step, what each of the docs from jboss, eclipse, jpa and richfaces told me, somebody missed to say I would need that packages, I think it's a RichFaces' fault, they could tell in the getting started docs that it'll need some extra packages from apache. Anyway, thankz for all that replied, I really appreciated you help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM