1

简短介绍:

我试图在 Jboss AS 7 上部署一个 jsf 2.1 项目(也在 Tomcat 7 上尝试过)。部署工作没有任何问题,但是当我尝试访问站点 css 时,找不到图像和 javascript,并且我从日志中得到大量以下异常类型:

0:04:58,261 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[Faces Servlet]] (http--127.0.0.1-8080-21) Servlet.service() for servlet Faces Servlet threw exception: com.sun.faces.context.FacesFileNotFoundException: /projectName/rfRes/calendarIcon.png.xhtml Not Found in ExternalContext as a Resource

在浏览器中它看起来像:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) 

例如,在模板中,图像如下所示:

<h:graphicImage library="images" name="logo.png" />

从人脸到资源的生成路径:

<img src="/projectName/javax.faces.resource/logo.png.xhtml;jsessionid=30AEAD88CADB047E3DFBDDA372732F08?ln=images">

图片路径:

WebContent/resources/images

我尝试使用不同的配置来部署它:Jboss 7.0/7.1、Tomcat 6/7、Java 6/7。但它仅适用于我的本地部署,不适用于 debian。一种解决方案是在不使用 jsf 的情况下将资源的直接路径放在任何地方,但是如何处理richfaces 图像和所有内容......

项目和系统配置:

Java 7
休眠 3
Jsf 2.1
Richfaces 4.2
Debian 6

人脸配置

<?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_0.xsd"
    version="2.0">
    <application> 
        <locale-config>
            <default-locale>en_EN</default-locale>
        </locale-config>
        <resource-bundle>
            <base-name>language</base-name>
            <var>language</var>
        </resource-bundle>
        <factory>
            <exception-handler-factory>
                package.ViewExceptionHandlerFactory
            </exception-handler-factory>
        </factory>
        <lifecycle>
            <phase-listener>package.AuthListener</phase-listener>
        </lifecycle>
    </application>
</faces-config>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app metadata-complete="true" id="WebApp_ID" version="3.0"
    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_3_0.xsd">
    <display-name>Name</display-name>
    <servlet id="JSF_Front_Controller_Servlet">
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>Jersey REST Service</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
            <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>package.services</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey REST Service</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
    <filter>
        <display-name>AuthFilter</display-name>
        <filter-name>AuthFilter</filter-name>
        <filter-class>package.AuthFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>AuthFilter</filter-name>
        <url-pattern>/view/user/*</url-pattern>
    </filter-mapping>
    <filter>
        <display-name>HibernateFilter</display-name>
        <filter-name>HibernateFilter</filter-name>
        <filter-class>package.HibernateFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>HibernateFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
        <listener-class>package.HibernateListener</listener-class>
    </listener>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>view/start.xhtml</welcome-file>
    </welcome-file-list>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>shadow</web-resource-name>
            <url-pattern>/services/payment/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
</web-app>

更新 1

好像是服务器问题。我使用 apache2 和以下虚拟主机运行 debian 6:

<VirtualHost *:80>
<Proxy *>
 Order deny,allow
 Allow from all
</Proxy>

 RewriteEngine On
 ProxyPreserveHost On

 RewriteRule ^/(.*)$  http://127.0.0.1:8080/project-name/$1 [P]

ServerName url.com
</VirtualHost>

重写规则对 jsf 来说是有问题的

4

0 回答 0