首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >jakarta.faces.FacesException:找不到CDI BeanManager- weld tomcat 10和JSF3,JDK11

jakarta.faces.FacesException:找不到CDI BeanManager- weld tomcat 10和JSF3,JDK11
EN

Stack Overflow用户
提问于 2021-07-08 18:56:33
回答 1查看 243关注 0票数 0

我要设置一个骨架与AdoptOpenJDK 11,tomcat 10.0.8,雅加达EE9,焊接和primefaces 10 jsf我已经看到了关于这个问题的几个帖子,并尝试了所有的修复,但似乎不能得到这个工作,项目将不会开始。我不断得到以下信息:

代码语言:javascript
运行
复制
08-Jul-2021 11:30:33.917 INFO [http-nio-8095-exec-10] org.jboss.weld.environment.servlet.EnhancedListener.onStartup WELD-ENV-001008: Initialize Weld using ServletContainerInitializer
08-Jul-2021 11:30:33.964 INFO [http-nio-8095-exec-10] org.jboss.weld.bootstrap.WeldStartup.<clinit> WELD-000900: 4.0.1 (Final)
08-Jul-2021 11:30:34.116 WARN [http-nio-8095-exec-10] org.jboss.weld.environment.servlet.WeldServletLifecycle.initialize WELD-ENV-000028: Weld initialization skipped - no bean archive found
08-Jul-2021 11:30:34.116 INFO [http-nio-8095-exec-10] org.jboss.weld.environment.servlet.Listener.contextInitialized WELD-ENV-001006: org.jboss.weld.environment.servlet.EnhancedListener used to initialize Weld
08-Jul-2021 11:30:34.174 INFO [http-nio-8095-exec-10] com.sun.faces.config.ConfigureListener.contextInitialized Initializing Mojarra 3.0.1 for context '/test'
08-Jul-2021 11:30:34.304 INFO [http-nio-8095-exec-10] com.sun.faces.spi.InjectionProviderFactory.createInstance JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.
08-Jul-2021 11:30:35.165 SEVERE [http-nio-8095-exec-10] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment: 
    jakarta.faces.FacesException: Unable to find CDI BeanManager
        at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:297)
        at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:227)
        at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:463)
        at com.sun.faces.application.applicationimpl.ExpressionLanguage.performOneTimeELInitialization(ExpressionLanguage.java:183)
        at com.sun.faces.application.applicationimpl.ExpressionLanguage.getELResolver(ExpressionLanguage.java:122)

我的pom是:

代码语言:javascript
运行
复制
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.chemnetbase</groupId>
    <artifactId>mavenproject4</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>mavenproject4-1.0</name>
    
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <jakartaee>9.1.0</jakartaee>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-api</artifactId>
            <version>${jakartaee}</version>
            <scope>provided</scope>
        </dependency>


        
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.faces</artifactId>
            <version>3.0.1</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.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-shaded</artifactId>
            <version>4.0.1.Final</version>
        </dependency>


        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>10.0.0</version>
            <classifier>jakarta</classifier>
        </dependency>
        


        
       
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>jakarta.platform</groupId>
                                    <artifactId>jakarta.jakartaee-api</artifactId>
                                    <version>${jakartaee}</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

beans.xml

代码语言:javascript
运行
复制
    <?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd" version="3.0">

</beans>

my faces-config.xml

代码语言:javascript
运行
复制
    <?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-facesconfig_3_0.xsd"
    version="3.0"
>
    <!-- Your faces config here. -->
</faces-config>

我的context.xml

代码语言:javascript
运行
复制
    <?xml version="1.0" encoding="UTF-8"?>
<Context path="">

<Resource name="BeanManager" 
        auth="Container"
        type="jakarta.enterprise.inject.spi.BeanManager"
        factory="org.jboss.weld.resources.ManagerObjectFactory"/>
   
</Context>

我的web.xml

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
  version="4.0"
  metadata-complete="true"
>
    <context-param>
        <param-name>org.jboss.weld.development</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>jakarta.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
    </context-param>
    <listener>
        <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
    </listener>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>
            jakarta.faces.webapp.FacesServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>        
    </session-config>
    <error-page>
        <exception-type>jakarta.faces.application.ViewExpiredException</exception-type>
        <location>/index.jsp</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/error.xhtml</location>
    </error-page>
   <welcome-file-list>
        <welcome-file>
         index.xhtml
        </welcome-file>
    </welcome-file-list>
    <resource-env-ref>
        <resource-env-ref-name>BeanManager</resource-env-ref-name>
        <resource-env-ref-type>
            jakarta.enterprise.inject.spi.BeanManager
        </resource-env-ref-type>
    </resource-env-ref>
</web-app>

我已经将我的beans.xml放在WEB-INF文件夹中:my project set up

我已经看了几个小时了,似乎找不到问题所在。如果有人能给我一些指导,我将不胜感激!谢谢

EN

回答 1

Stack Overflow用户

发布于 2021-07-12 17:57:44

我想我找到问题所在了,web.xml中的声明。现在似乎起作用了!<web-app xmlns="jakarta.ee/xml/ns/jakartaee" xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:schemaLocation="jakarta.ee/xml/ns/jakartaee jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd" version="5.0" metadata-complete="true">

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68300307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档