javax.faces.FacesException: Class org.jboss.as.jsf.injection.JandexAnnotationProvider 不是 com.sun.faces.spi.AnnotationProvider 的实例

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

我使用:Maven 3.3.1、Java SE 1.8、JavaServerFaces 2.2、JPA 2.0、Spring 4.1.6、Hibernate 4.3。2.Final 和野蝇。 我是J2EE的新手,请给我详细的指导。

我的堆栈跟踪:

     09:52:31,461 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Critical error during deployment: : com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Class org.jboss.as.jsf.injection.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:357) [javax.faces-2.0.10.jar:2.0.10-SNAPSHOT]
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:220) [javax.faces-2.0.10.jar:2.0.10-SNAPSHOT]
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:193) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75]
    Caused by: javax.faces.FacesException: Class org.jboss.as.jsf.injection.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.spi.AnnotationProviderFactory.createAnnotationProvider(AnnotationProviderFactory.java:78) [javax.faces-2.0.10.jar:2.0.10-SNAPSHOT]
at com.sun.faces.config.ConfigManager$AnnotationScanTask.<init>(ConfigManager.java:752) [javax.faces-2.0.10.jar:2.0.10-SNAPSHOT]
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:330) [javax.faces-2.0.10.jar:2.0.10-SNAPSHOT]
... 10 more

    09:52:31,472 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./Ear_Project: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./Ear_Project: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75]
     Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Class org.jboss.as.jsf.injection.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:222)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 more
    Caused by: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Class org.jboss.as.jsf.injection.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:287)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:193)
... 7 more
    Caused by: com.sun.faces.config.ConfigurationException:   CONFIGURATION FAILED! Class org.jboss.as.jsf.injection.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:357)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:220)
... 9 more
    Caused by: javax.faces.FacesException: Class org.jboss.as.jsf.injection.JandexAnnotationProvider is not an instance of com.sun.faces.spi.AnnotationProvider
at com.sun.faces.spi.AnnotationProviderFactory.createAnnotationProvider(AnnotationProviderFactory.java:78)
at com.sun.faces.config.ConfigManager$AnnotationScanTask.<init>(ConfigManager.java:752)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:330)
... 10 more

JandexAnnotationProvider 实际上是从 AnnotationProvider class 扩展而来的,如果两个 class 都是通过不同的 class 加载器加载的,则可能会导致此类错误。

我认为您必须将 jsf-api-???.jarjsf-impl-???.jar 排除在与您的应用程序一起部署的蜜蜂之外。使用应用程序服务器提供的 jsf 库。

要使用 Maven 实现它,只需将 <scope>provided</scope> 设置为 jsf-apijsf-impl 依赖项 pom.xml