我安装了Weblogic 10.3.5。我在服务器上部署了 JSF 2.0 war。在我的 WebContent
文件夹中,有 *.xhtml 和 *.jsp 文件,它们分别包含 JSF2.0 xhtml 和纯 JSP 代码。当我导航到 http://localhost:7001/MyApp/NewFile123.xhtml
时,我收到 404 Not found
错误页面。 (Eclipse 控制台上没有任何信息)。但是 http://localhost:7001/MyApp/NewFile.jsp
工作得很好并且做了它应该做的事情。
我没有混合 JSF 和 JSP,只是想看看 JSP 是否能工作。我有适合 XHTML 文件的 servlet 映射。
我的类路径上也有这些:
-
glassfish.el_1.0.0.0_2-2.jar
-
glassfish.jsf_1.0.0.0_2-1- 5.jar
-
glassfish.jstl_1.2.0.2.jar
-
javax.servlet_1.0.0.0_2-5.jar
另一个有趣的事情是,当我尝试编辑 *.xhtml 文件时,自动完成功能不起作用。 (即它不会自动完成。它曾经在我使用Weblogic 12.1时自动完成,它具有开箱即用的JSF2.0。
编辑:这里是web.xml 的相关部分
<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>*.xhtml</url-pattern>
</servlet-mapping>
那么,当我尝试导航到 JSF 页面时,为什么会收到 404 错误?有什么建议吗?
I have Weblogic 10.3.5 installed. I deployed the JSF 2.0 war on the server. In my WebContent
folder, I have *.xhtml and *.jsp files, which contain JSF2.0 xhtml and pure JSP code, respectively. When I navigate to http://localhost:7001/MyApp/NewFile123.xhtml
, I get a 404 Not found
error page. (Nothing informative on the Eclipse console). But http://localhost:7001/MyApp/NewFile.jsp
works well and does what it's supposed to do.
I am not mixing JSF and JSP but just wanted to see if JSP is gonna work. I have the appropriate servlet-mapping for the XHTML files.
I also have these on my classpath:
-
glassfish.el_1.0.0.0_2-2.jar
-
glassfish.jsf_1.0.0.0_2-1-5.jar
-
glassfish.jstl_1.2.0.2.jar
-
javax.servlet_1.0.0.0_2-5.jar
Another interesting thing, when I try to edit the *.xhtml files, the auto-complete doesn't work. (i.e it won't autocomplete <h:outp
. It used to when I was using Weblogic 12.1 which has JSF2.0 out of the box.
Edit: Here is the relevant part of web.xml
<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>*.xhtml</url-pattern>
</servlet-mapping>
So why do I get a 404 when I try to navigate to a JSF page? Any suggestions?
发布评论
评论(1)
从
/WEB-INF/lib
中删除所有这些特定于容器的库。它们根本不属于那里,集装箱已经随它们一起运输了。您的/WEB-INF/lib
应仅包含容器未附带的特定于 Web 应用程序的库。您的问题很可能是由于 Weblogic 1.0.3.5 是一个 Servlet 2.5 容器,它已经随 JSF 2.0 一起提供,但您提供的 JSF 2.1 库需要 Servlet 3.0。我不使用 Weblogic,但我了解到 1.0.3.x 需要一些特定步骤才能使 JSF 2.0 正常工作,另请参阅 此博客。以下是相关性的摘录:
按照注释更新:
这可能会生成一个兼容 JSF 1.2 的
faces-config.xml
,这将强制 JSF 2.0 以 JSF 1.2 方式运行。您需要重新声明
根声明以符合 JSF 2.0。Remove all those container-specific libraries from your
/WEB-INF/lib
. They do not belong there at all, the container already ships with them. Your/WEB-INF/lib
should contain only the webapp-specific libraries which are not shipped with the container.Your problem is most likely caused by the fact that Weblogic 1.0.3.5 is a Servlet 2.5 container which already ships with JSF 2.0, but that you're supplying a JSF 2.1 library which requires Servlet 3.0. I don't use Weblogic, but I've read that 1.0.3.x requires some specific steps to get JSF 2.0 to work, see also this blog. Here's an extract of relevance:
Update as per the comments:
That might have generated a JSF 1.2 compliant
faces-config.xml
which would force JSF 2.0 to run in JSF 1.2 modus. You need to redeclare the<faces-config>
root declaration to comply JSF 2.0.