找不到CDI BeanManager

时间:2019-01-03 12:00:30

标签: java maven spring-boot wildfly

我正在尝试建立一个简单的应用程序以在Wildfly 14上使用SpringBoot 2.1.1和Java 11(因为Eclipse不支持Wildfly 15)。

部署失败,因为Wildfly在项目中找不到CDI BeanManager。我只是尝试遵循简单的(官方)教程,所以我不明白为什么会出现错误。

这是代码:

pom.xml

<properties>
    <start-class>main</start-class>
</properties>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
</parent>

<!-- Add typical dependencies for a web application -->
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

<!-- Package as an executable jar -->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Application.java

package main;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAutoConfiguration
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

这是堆栈跟踪:

  

12:51:13,365信息[org.jboss.as.server.deployment](MSC服务线程1-8)WFLYSRV0027:开始部署“ SpringBoot-0.0.1.war”(运行时名称:“ SpringBoot- 0.0.1.war“)   警告:发生了非法的反射访问操作   警告:io.undertow.util.FlexBase64 $ 1(jar:file:/ C:/ Users / 87003556 / Documents / Java / Wildfly%2014 / modules / system / layers / base / io / undertow / core / main的非法反射访问/undertow-core-2.0.13.Final.jar!/)到构造函数java.lang.String(char [],boolean)   警告:请考虑将此报告给io.undertow.util.FlexBase64 $ 1的维护者   警告:使用--illegal-access = warn启用有关进一步非法反射访问操作的警告   警告:所有非法访问操作将在以后的版本中被拒绝   12:51:13,429信息[org.wildfly.extension.undertow](MSC服务线程1-6)WFLYUT0006:Undertow HTTPS侦听器https侦听127.0.0.1:8443   12:51:13,531信息[org.jboss.ws.common.management](MSC服务线程1-8)JBWS022052:启动JBossWS 5.2.3.Final(Apache CXF 3.2.5.jbossorg-1)   12:51:15,606警告[org.jboss.as.ee](MSC服务线程1-1)WFLYEE0007:由于异常(未安装可选组件org.springframework.http.server.reactive.ServletServerHttpResponse $ ResponseAsyncListener(启用DEBUG日志)水平看原因)   12:51:15,606警告[org.jboss.as.ee](MSC服务线程1-1)WFLYEE0007:由于异常(未启用调试日志,因此未安装可选组件org.springframework.http.server.reactive.ServletHttpHandlerAdapter $ HandlerResultAsyncListener)水平看原因)   12:51:15,622 WARN [org.jboss.as.ee](MSC服务线程1-1)WFLYEE0007:由于异常而未安装可选组件org.springframework.http.server.ServletServerHttpAsyncRequestControl(启用DEBUG日志级别以查看原因)   12:51:15,622 WARN [org.jboss.as.ee](MSC服务线程1-1)WFLYEE0007:由于异常而未安装可选组件org.springframework.web.context.request.async.StandardServletAsyncWebRequest(启用DEBUG日志)水平看原因)   12:51:15,622警告[org.jboss.as.ee](MSC服务线程1-1)WFLYEE0007:由于异常(未启用调试日志,未安装可选组件org.springframework.http.server.reactive.ServletServerHttpRequest $ RequestAsyncListener)水平看原因)   12:51:15,794 INFO [org.infinispan.factories.GlobalComponentRegistry](MSC服务线程1-7)ISPN000128:Infinispan版本:Infinispan'Estrella Galicia'9.3.1.Final   12:51:15,966 INFO [org.jboss.as.clustering.infinispan](ServerService线程池-72)WFLYCLINF0002:从ejb容器启动了客户端映射缓存   12:51:16,075 INFO [io.undertow.servlet](ServerService线程池-85)1在类路径上检测到Spring WebApplicationInitializers   12:51:16,153 INFO [javax.enterprise.resource.webcontainer.jsf.config](ServerService线程池-85)为上下文'/SpringBoot-0.0.1'初始化Mojarra 2.3.5.SP2   12:51:16,761严重[javax.enterprise.resource.webcontainer.jsf.config](ServerService线程池-85)部署期间的严重错误::com.sun.faces.config.ConfigurationException:工厂'javax.faces.lifecycle .ClientWindowFactory'配置不正确。     在com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:357)     在com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:243)     在com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:443)     在com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:237)     在io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)     在io.undertow.servlet.core.DeploymentManagerImpl $ 1.call(DeploymentManagerImpl.java:216)     在io.undertow.servlet.core.DeploymentManagerImpl $ 1.call(DeploymentManagerImpl.java:185)     在io.undertow.servlet.core.ServletRequestContextThreadSetupAction $ 1.call(ServletRequestContextThreadSetupAction.java:42)     在io.undertow.servlet.core.ContextClassLoaderSetupAction $ 1.call(ContextClassLoaderSetupAction.java:43)     ...     在org.jboss.threads.JBossThread.run(JBossThread.java:485)   原因:javax.faces.FacesException:无法找到CDI BeanManager     在com.sun.faces.application.ApplicationImpl.isJsf23(ApplicationImpl.java:2714)     在com.sun.faces.application.ApplicationImpl.addELResolver(ApplicationImpl.java:549)     ...     在javax.faces.FactoryFinder.getFactory(FactoryFinder.java:292)     在com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:354)     ...还有29个

     

12:51:16,761错误[org.jboss.msc.service.fail](服务器服务线程池-85)MSC000001:无法启动服务jboss.deployment.unit。“ SpringBoot-0.0.1.war”。 Undertow部署:服务jboss.deployment.unit中的org.jboss.msc.service.StartException。“ SpringBoot-0.0.1.war”。undertow部署:java.lang.RuntimeException:java.lang.RuntimeException:com.sun .faces.config.ConfigurationException:未正确配置工厂'javax.faces.lifecycle.ClientWindowFactory'。     在org.wildfly.extension.undertow.deployment.UndertowDeploymentService $ 1.run(UndertowDeploymentService.java:81)     在java.base / java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:515)     ...     在java.base / java.lang.Thread.run(Thread.java:825)     在org.jboss.threads.JBossThread.run(JBossThread.java:485)   引起原因:java.lang.RuntimeException:java.lang.RuntimeException:com.sun.faces.config.ConfigurationException:工厂'javax.faces.lifecycle.ClientWindowFactory'未正确配置。     在io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:252)     在org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)     在org.wildfly.extension.undertow.deployment.UndertowDeploymentService $ 1.run(UndertowDeploymentService.java:78)     ...另外8个   引起原因:java.lang.RuntimeException:com.sun.faces.config.ConfigurationException:未正确配置工厂'javax.faces.lifecycle.ClientWindowFactory'。     在com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:315)     在io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)     在io.undertow.servlet.core.DeploymentManagerImpl $ 1.call(DeploymentManagerImpl.java:216)     在io.undertow.servlet.core.DeploymentManagerImpl $ 1.call(DeploymentManagerImpl.java:185)     在io.undertow.servlet.core.ServletRequestContextThreadSetupAction $ 1.call(ServletRequestContextThreadSetupAction.java:42)     ...     在io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:250)     ...还有10个   引起原因:com.sun.faces.config.ConfigurationException:未正确配置工厂'javax.faces.lifecycle.ClientWindowFactory'。     在com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:357)     ...     在com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:237)     ...另外26个   原因:javax.faces.FacesException:无法找到CDI BeanManager     在com.sun.faces.application.ApplicationImpl.isJsf23(ApplicationImpl.java:2714)     在com.sun.faces.application.ApplicationImpl.addELResolver(ApplicationImpl.java:549)     在org.jboss.as.jsf.injection.weld.WeldApplication。(WeldApplication.java:60)     在org.jboss.as.jsf.injection.weld.WeldApplicationFactory.getApplication(WeldApplicationFactory.java:52)     在com.sun.faces.application.InjectionApplicationFactory.getApplication(InjectionApplicationFactory.java:88)     ...位于javax.faces.FactoryFinder.getFactory(FactoryFinder.java:292)     在com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:354)     ...还有29个

     

12:51:16,762错误[org.jboss.as.controller.management-operation](控制器引导线程)​​WFLYCTL0013:操作(“ deploy”)失败-地址:([(“ deployment” =>“ SpringBoot- 0.0.1.war“)])-失败描述:{” WFLYCTL0080:失败的服务“ => {” jboss.deployment.unit。\“ SpringBoot-0.0.1.war \”。undertow-deployment“ =>” java .lang.RuntimeException:java.lang.RuntimeException:com.sun.faces.config.ConfigurationException:未正确配置工厂'javax.faces.lifecycle.ClientWindowFactory'。       引起原因:java.lang.RuntimeException:java.lang.RuntimeException:com.sun.faces.config.ConfigurationException:工厂'javax.faces.lifecycle.ClientWindowFactory'未正确配置。       引起原因:java.lang.RuntimeException:com.sun.faces.config.ConfigurationException:未正确配置工厂'javax.faces.lifecycle.ClientWindowFactory'。       引起原因:com.sun.faces.config.ConfigurationException:未正确配置工厂'javax.faces.lifecycle.ClientWindowFactory'。       原因:javax.faces.FacesException:无法找到CDI BeanManager“}}   12:51:16,762 INFO [org.jboss.as.server](ServerService线程池-42)WFLYSRV0010:部署了“ SpringBoot-0.0.1.war”(运行时名称:“ SpringBoot-0.0.1.war”)   12:51:16,762信息[org.jboss.as.controller](控制器引导线程)​​WFLYCTL0183:服务状态报告   WFLYCTL0186:无法启动的服务:service jboss.deployment.unit。“ SpringBoot-0.0.1.war” .undertow-deployment:java.lang.RuntimeException:java.lang.RuntimeException:com.sun.faces.config.ConfigurationException :工厂'javax.faces.lifecycle.ClientWindowFactory'的配置不正确。

2 个答案:

答案 0 :(得分:2)

正如我们在评论中讨论的那样,解决方案可能很简单,只需将cdi-api添加到您的 pom.xml 依赖项中即可。它不包含在您指定的依赖项中。

<dependency> 
    <groupId>javax.enterprise</groupId> 
    <artifactId>cdi-api</artifactId> 
    <version>1.2</version> 
</dependency>

答案 1 :(得分:1)

记住,必须包含启动CDI配置的上下文。

<Resource name="BeanManager" auth="Container" type="javax.enterprise.inject.spi.BeanManager" factory="org.apache.webbeans.container.ManagerObjectFactory" />

You can check the all setup here

或者您可以查看此blog