gpt4 book ai didi

java - JSF + RichFaces 在我的页面中提供 HTTP 状态 404

转载 作者:行者123 更新时间:2023-12-02 08:35:45 26 4
gpt4 key购买 nike

可能这是一个缺乏注意力的问题,如果是这样,请原谅我,但我看不出我做错了什么,花了我一下午的时间,我需要你的帮助。

我正在做一个 JSF + JPA + RichFaces 应用程序,它非常简单。我做了 JPA 项目,进行了测试,然后进行了 JSF 项目,进行了测试,一切工作正常,但是当我将 RichFaces jar 粘贴到 WEB-INF/lib 文件夹中时,甚至在我进行任何更改之前,正在工作的页面就停止了,现在我得到一个 HTTP 状态 404 页面,就像我输入了错误的地址一样,但我使用的地址与以前相同。

这是我的 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>

还有我的 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>

我认为我的 JPA 项目与此错误没有关系,因为它是一个独立的项目并且工作正常。

我的文件夹结构类似于

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

网址http://localhost:8080/Monaco/faces/cadastro/pessoa/listar.jsp曾经在 RichFaces jars 之前工作过,但现在我得到了:

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

我尝试了很多网址变体,例如:

在所有这些中,我收到相同的错误(应该没问题),但我无法理解为什么它停止只是因为我添加了 RichFaces jars...

谢谢家伙!

一些应用程序服务器日志:

16:43:28,879 ERROR [[/Monaco]] Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListenerjavax.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 moreCaused 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 moreCaused 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 more16:43:28,879 ERROR [StandardContext] Error listenerStart16:43:28,879 ERROR [StandardContext] Context [/Monaco] startup failed due to previous errors

再见。

最佳答案

您需要将网页内容文件放入 /faces 根文件夹中,路径与 URL 中的路径完全相同。

另一种方法是将 /faces/*url-pattern 替换为 *.jsf,这样您就可以在不使用/faces 路径,例如:http://localhost:8080/Monaco/cadastro/pessoa/listar.jsf。顺便说一句,您不需要需要将实际的 .jsp 文件重命名为 .jsf

如果您想阻止直接访问 JSP 文件(否则将能够请求 .jsp 文件并遇到 RuntimeException: FacesContext not found),那么您最好将文件(包括文件夹结构)移动到 WEB-INF 文件夹中。

希望这有帮助。

编辑:您添加了应用程序服务器日志。第一个问题的根本原因如下:

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

这是相当不言自明的:运行时类路径中缺少提到的类。正如包名称已经暗示它是 Apache Commons Digester,您可以从 http://commons.apache.org/digester 获取它。 。将其放入运行时类路径 (WEB-INF/lib) 中并重新启动。看看后续的错误是否会消失(可能是由同一问题间接引起的)。如果没有,请返回并编辑问题中的堆栈跟踪(不要忘记选择它并按代码按钮 (0101011010) 或按 Ctrl+K)。

关于java - JSF + RichFaces 在我的页面中提供 HTTP 状态 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1863559/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com