gpt4 book ai didi

java - 如何在 JBoss AS 7.1.1 Final 中使用 JSF 2.1.14 Mojarra、Servlet 3.0 和 EL 2.2?

转载 作者:行者123 更新时间:2023-12-04 05:19:05 26 4
gpt4 key购买 nike

在我的应用程序中,我想将 JSF 2.1.14 Mojarra 与 Servlet 3.0 和 EL 2.2 一起使用。服务器是 JBoss-AS-7.1.1-Final。

现在我已经在 pom.xml 中添加了这些依赖项:

<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.14</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.14</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>

这些 jar 在/WEB-INF/lib 中。在控制台的容器中部署应用程序后,我可以看到一个日志:
18:15:02,278 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-12) Initializing Mojarra 2.1.7-jbossorg-1 (20120227-1401) for context '/ActivityDatabase'

这显然意味着 JBoss 没有使用我放在 war 文件中的 JSF 版本。

在谷歌搜索和搜索其他 SO 线程后,我发现了 here ,我需要告诉容器使用 WAR 文件中提供的 JSF 包。所以我补充说:
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>

在我的 web.xml 中。之后,当我部署 war 时,在部署时出现异常:
18:39:57,665 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-8) Critical error during deployment: : com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:376) [jsf-impl-2.1.14.jar:2.1.14]
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:223) [jsf-impl-2.1.14.jar:2.1.14]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]
Caused by: javax.faces.FacesException: Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.spi.AnnotationProviderFactory.createAnnotationProvider(AnnotationProviderFactory.java:78) [jsf-impl-2.1.14.jar:2.1.14]
at com.sun.faces.config.ConfigManager$AnnotationScanTask.<init>(ConfigManager.java:808) [jsf-impl-2.1.14.jar:2.1.14]
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:349) [jsf-impl-2.1.14.jar:2.1.14]
... 9 more

18:39:57,696 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ActivityDatabase]] (MSC service thread 1-8) Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvi
der is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:290) [jsf-impl-2.1.14.jar:2.1.14]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]
Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:376) [jsf-impl-2.1.14.jar:2.1.14]
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:223) [jsf-impl-2.1.14.jar:2.1.14]
... 8 more
Caused by: javax.faces.FacesException: Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.spi.AnnotationProviderFactory.createAnnotationProvider(AnnotationProviderFactory.java:78) [jsf-impl-2.1.14.jar:2.1.14]
at com.sun.faces.config.ConfigManager$AnnotationScanTask.<init>(ConfigManager.java:808) [jsf-impl-2.1.14.jar:2.1.14]
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:349) [jsf-impl-2.1.14.jar:2.1.14]
... 9 more

18:39:57,743 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Error listenerStart
18:39:57,758 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Context [/ActivityDatabase] startup failed due to previous errors
18:39:57,758 SEVERE [javax.faces] (MSC service thread 1-8) Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory. Attempting to find backup.
18:39:57,758 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-8) Unexpected exception when attempting to tear down the Mojarra runtime: java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory.
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1010) [jsf-api-2.1.14.jar:2.1]
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:342) [jsf-api-2.1.14.jar:2.1]
at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:136) [jsf-impl-2.1.14.jar:2.1.14]
at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:328) [jsf-impl-2.1.14.jar:2.1.14]
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3489) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3999) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3917) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]

18:39:57,805 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.web.deployment.default-host./ActivityDatabase: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ActivityDatabase: JBAS018040: Failed to start context
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_09]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]

18:39:57,821 INFO [org.jboss.as] (MSC service thread 1-8) JBAS015951: Admin console listening on http://127.0.0.1:9990
18:39:57,836 ERROR [org.jboss.as] (MSC service thread 1-8) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 4446ms - Started 444 of 523 services (2 services failed or missing dependencies, 76 services are passive or on-demand)
18:39:58,039 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "ActivityDatabase.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./ActivityDatabase" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ActivityDatabase: JBAS018040: Failed to start context"}}
18:39:58,179 INFO [org.jboss.as.server.deployment] (MSC service thread 1-16) JBAS015877: Stopped deployment ActivityDatabase.war in 145ms
18:39:58,179 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.web.deployment.default-host./ActivityDatabase: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ActivityDatabase: JBAS018040: Failed to start context

18:39:58,179 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./ActivityDatabase" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ActivityDatabase: JBAS01
8040: Failed to start context"}}}}

我还尝试将 jsf 模块从 jboss-deployment-structure.xml 中排除为:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="javax.faces.api" />
<module name="com.sun.jsf-impl" />
<module name="javax.faces.api" />
<module name="com.sun.jsf-impl" />
</exclusions>
</deployment>
</jboss-deployment-structure>

但没有运气,同样的错误。我仍在网上搜索解决方案,但没有任何效果。我也不确定 JBoss 是否使用 Servlet 3.0 和 EL 2.2。虽然我指定了 version="3.0"在 web.xml 中。
<?xml version="1.0" encoding="UTF-8"?>
<web-app
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"
version="3.0">

---

</web-app>

任何建议都会对我很有帮助。

最佳答案

Caused by: javax.faces.FacesException: Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider



这是第一次在 JBoss 7.1.0 中发现并在 JBoss 7.1.3 中修复的错误,另见 JBoss AS 7 issue 3940 .

因此,至少升级到 7.1.3 应该可以解决它。

关于java - 如何在 JBoss AS 7.1.1 Final 中使用 JSF 2.1.14 Mojarra、Servlet 3.0 和 EL 2.2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13879481/

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