简体   繁体   English

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

[英]How to use JSF 2.1.14 Mojarra, Servlet 3.0 and EL 2.2 in JBoss AS 7.1.1 Final?

In my application I want to use JSF 2.1.14 Mojarra with Servlet 3.0 and EL 2.2.在我的应用程序中,我想将 JSF 2.1.14 Mojarra 与 Servlet 3.0 和 EL 2.2 一起使用。 The server is JBoss-AS-7.1.1-Final.服务器是 JBoss-AS-7.1.1-Final。

Now that I have added these dependency in pom.xml:现在我已经在 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>

These jars are in the /WEB-INF/lib.这些 jar 文件位于 /WEB-INF/lib 中。 After deploying the application in the container in the console I can see a log:在控制台的容器中部署应用程序后,我可以看到一个日志:

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'

This clearly means that JBoss is not using the JSF version that I have placed within the war file.这显然意味着 JBoss 没有使用我放置在 war 文件中的 JSF 版本。

After Googling and searching other SO threads I found here , that I need to tell the container to use the JSF bundles provided in the WAR file.在谷歌搜索并搜索我在这里找到的其他 SO 线程之后,我需要告诉容器使用 WAR 文件中提供的 JSF 包。 So I have added:所以我补充说:

<context-param>
    <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
    <param-value>true</param-value>
</context-param>

In my web.xml.在我的 web.xml 中。 After that when I deployed the war, at the time of deployment I am getting Exception:之后,当我部署战争时,在部署时出现异常:

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"}}}}

I have also tried to exclude the jsf module from jboss-deployment-structure.xml as:我还尝试从 jboss-deployment-structure.xml 中排除 jsf 模块:

<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> 

But no luck, same error.但没有运气,同样的错误。 I am still searching web for a solution but nothing is working.我仍在网上搜索解决方案,但没有任何效果。 Also I am not sure whether or not JBoss is using Servlet 3.0 and EL 2.2.另外我不确定 JBoss 是否使用 Servlet 3.0 和 EL 2.2。 Although I have specified version="3.0" in web.xml.虽然我在 web.xml 中指定了version="3.0"

<?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>

Any suggestion will be very helpful to me.任何建议都会对我很有帮助。

Caused by: javax.faces.FacesException: Class org.jboss.as.web.deployment.jsf.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider引起:javax.faces.FacesException:类 org.jboss.as.web.deployment.jsf.JandexAnnotationProvider 不是 com.sun.faces.spi.AnnotationProvider 的实例

This is a bug which was discovered for first time in JBoss 7.1.0 and is fixed in JBoss 7.1.3, see also JBoss AS 7 issue 3940 .这是在 JBoss 7.1.0 中首次发现并在 JBoss 7.1.3 中修复的错误,另请参阅JBoss AS 7 问题 3940

So, upgrading to at least 7.1.3 should fix it.因此,升级到至少 7.1.3 应该可以修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM