我正在尝试将应用程序从 Tomcat 9 和 PrimeFaces 13 迁移到 Tomcat 10.1.11 和 Java 17。在完成所有繁重的工作之后,除了 PrimeIcon 图像的 PrimeFaces 显示(它们没有从 Tomcat 实例中拉下来)。
在尝试解决该问题时,我创建了一个示例项目,其中仅包含 PrimeFaces v13 Showcase 中的 CommandButton 页面 - 这就是它应该的样子:
但是,我在 Tomcat 10 托管页面中看到的是:
PrimeIcons css 和相关文件包含在 PrimeFaces jar 中(通过解压缩 jar 进行验证),但是当收到 index.xhtml 请求时,Tomcat 的本地主机日志文件中会记录两个错误:
2024 年 12 月 5 日 10:34:44.784 严重 [http-nio-80-exec-4] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Faces Servlet] in context with path [ /proto2] 抛出异常 jakarta.el.PropertyNotFoundException:在类型 [com.sun.faces.cdi.CdiExtension$$OwbNormalScopeProxy0] 上找不到属性 [primefaces:datascroller/images/loading.gif] 在 jakarta.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:261) 在 jakarta.el.BeanELResolver.property(BeanELResolver.java:330) 在 jakarta.el.BeanELResolver.getValue(BeanELResolver.java:99)
2024 年 12 月 5 日 10:34:44.793 严重 [http-nio-80-exec-3] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Faces Servlet] in context with path [ /proto2] 抛出异常 jakarta.el.PropertyNotFoundException:在类型 [com.sun.faces.cdi.CdiExtension$$OwbNormalScopeProxy0] 上找不到属性 [primefaces:primeicons/primeicons.eot] 在 jakarta.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:261) 在 jakarta.el.BeanELResolver.property(BeanELResolver.java:330) 在 jakarta.el.BeanELResolver.getValue(BeanELResolver.java:99)
通过回滚到各种
javax.*
包而不是 jakarta.*
并使用 Tomcat 9,primeicon 图像将按预期应用,如上面的“预期”图像所示,该图像由运行 Java 的 Tomcat 9.0.50 提供11
任何想法、建议、想法都将不胜感激。
托马斯
index.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
<f:view contentType="text/html;charset=UTF-8" encoding="UTF-8">
<h:head>
</h:head>
<h:body>
<style>
button.ui-button {
margin-right: .5rem;
}
</style>
<div class="card">
<h5>Rounded Icon Buttons</h5>
<p:commandButton type="button" icon="pi pi-bookmark" styleClass="rounded-button ui-button-secondary" />
<p:commandButton type="button" icon="pi pi-search" styleClass="rounded-button ui-button-success" />
<p:commandButton type="button" icon="pi pi-user" styleClass="rounded-button ui-button-info" />
<p:commandButton type="button" icon="pi pi-bell" styleClass="rounded-button ui-button-warning" />
<p:commandButton type="button" icon="pi pi-heart" styleClass="rounded-button ui-button-help" />
<p:commandButton type="button" icon="pi pi-times" styleClass="rounded-button ui-button-danger" />
<p:commandButton type="button" icon="pi pi-check" styleClass="rounded-button" />
<h5>Rounded Text Icon Buttons</h5>
<p:commandButton type="button" icon="pi pi-check" styleClass="rounded-button ui-button-flat" />
<p:commandButton type="button" icon="pi pi-bookmark" styleClass="rounded-button ui-button-secondary ui-button-flat" />
<p:commandButton type="button" icon="pi pi-search" styleClass="rounded-button ui-button-success ui-button-flat" />
<p:commandButton type="button" icon="pi pi-user" styleClass="rounded-button ui-button-info ui-button-flat" />
<p:commandButton type="button" icon="pi pi-bell" styleClass="rounded-button ui-button-warning ui-button-flat" />
<p:commandButton type="button" icon="pi pi-heart" styleClass="rounded-button ui-button-help ui-button-flat" />
<p:commandButton type="button" icon="pi pi-times" styleClass="rounded-button ui-button-danger ui-button-flat" />
<p:commandButton type="button" icon="pi pi-filter" styleClass="rounded-button ui-button-flat ui-button-plain" />
<h5>Rounded and Outlined Icon Buttons</h5>
<p:commandButton type="button" icon="pi pi-check" styleClass="rounded-button ui-button-outlined" />
<p:commandButton type="button" icon="pi pi-bookmark" styleClass="rounded-button ui-button-secondary ui-button-outlined" />
<p:commandButton type="button" icon="pi pi-search" styleClass="rounded-button ui-button-success ui-button-outlined" />
<p:commandButton type="button" icon="pi pi-user" styleClass="rounded-button ui-button-info ui-button-outlined" />
<p:commandButton type="button" icon="pi pi-bell" styleClass="rounded-button ui-button-warning ui-button-outlined" />
<p:commandButton type="button" icon="pi pi-heart" styleClass="rounded-button ui-button-help ui-button-outlined" />
<p:commandButton type="button" icon="pi pi-times" styleClass="rounded-button ui-button-danger ui-button-outlined" />
<style>
html body .custom.ui-button.ui-button-text-only .ui-icon-loading {
opacity: 0;
}
html body .custom.ui-button.ui-button-text-only .ui-icon-loading:before {
content: "\e94a";
}
html body .custom.ui-button,
html body .custom.ui-button * {
transition-property: all;
transition-duration: .2s;
}
html body .custom.ui-button.ui-state-loading {
opacity: 1;
background: #888;
border-color: #888;
}
html body .custom.ui-button.ui-state-loading.ui-button-text-only .ui-button-text {
opacity: 1;
padding-left: 2rem;
}
html body .custom.ui-button.ui-state-loading.ui-button-text-only .ui-icon-loading {
opacity: 1;
left: 0;
margin-left: 0.5rem;
}
</style>
</div>
</h:body>
</f:view>
</html>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://java.sun.com/xml/ns/javaee" xsi:schemaLocation="https://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="NMPT" version="2.5">
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<display-name>Proto2 v${project.version}</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>saga</param-value>
</context-param>
<context-param>
<param-name>primefaces.MOVE_SCRIPTS_TO_BOTTOM</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>jakarta.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>ttf</extension>
<mime-type>application/font-sfnt</mime-type>
</mime-mapping>
<mime-mapping>
<extension>woff</extension>
<mime-type>application/font-woff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>woff2</extension>
<mime-type>application/font-woff2</mime-type>
</mime-mapping>
<mime-mapping>
<extension>eot</extension>
<mime-type>application/vnd.ms-fontobject</mime-type>
</mime-mapping>
<mime-mapping>
<extension>eot?#iefix</extension>
<mime-type>application/vnd.ms-fontobject</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg</extension>
<mime-type>image/svg+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg#latobold</extension>
<mime-type>image/svg+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg#latoblack</extension>
<mime-type>image/svg+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg#latolight</extension>
<mime-type>image/svg+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg#latoregular</extension>
<mime-type>image/svg+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg#fontawesomeregular</extension>
<mime-type>image/svg+xml</mime-type>
</mime-mapping>
</web-app>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.me</groupId>
<artifactId>proto2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>proto2</name>
<description>test JSF project for working out PrimeFaces issues</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<primefaces.version>13.0.10</primefaces.version>
<tomcat.version>10.1.11</tomcat.version>
<log4j.version>2.20.0</log4j.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0.2</version>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
<configuration>
<validationSets>
<validationSet>
<dir>src/main/webapp</dir>
<includes>
<include>**/*.xhtml</include>
</includes>
</validationSet>
</validationSets>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>html-types</artifactId>
<version>20220608.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.faces</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-el22</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-juli</artifactId>
<version>${tomcat.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>${tomcat.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>4.0.5</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.5</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-digester3</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-jakarta-servlet6</artifactId>
<version>2.0.0-M2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math4-core</artifactId>
<version>4.0-beta1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>commons-el</groupId>
<artifactId>commons-el</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
</dependency>
</dependencies>
</project>
请升级到 Mojarra 4.0.9,因为这是 Mojarra 中修复的错误!