[英]OpenWebBeans gives error java.lang.NoClassDefFoundError when using with Tomcat 10
I am trying to use OpenWebBeans with Tomcat 10. I have followed the steps given in this link .我正在尝试将 OpenWebBeans 与 Tomcat 10 一起使用。我已按照此链接中给出的步骤进行操作。
When I use Weld, it works fine.当我使用 Weld 时,它工作正常。 But when I use OpenWebBeans, I get the following error.但是当我使用 OpenWebBeans 时,出现以下错误。
SEVERE: Error configuring application listener of class [org.apache.webbeans.servlet.WebBeansConfigurationListener]
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener ...
My pom file is as follows我的pom文件如下
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>minimal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.faces</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf</artifactId>
<version>2.0.21</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>7.0.1.Final</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
</dependency>
</dependencies>
</project>
This is my web.xml这是我的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>minimal</display-name>
<servlet>
<servlet-name>facesServlet</servlet-name>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<listener>
<listener-class>
org.apache.webbeans.servlet.WebBeansConfigurationListener
</listener-class>
</listener>
This is my context.xml这是我的上下文。xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE XML>
<Context>
<Resource name="BeanManager"
auth="Container"
type="jakarta.enterprise.inject.spi.BeanManager"
factory="org.apache.webbeans.container.ManagerObjectFactory" />
</Context>
I am required to migrate to the jakarta namespace using OpenWebBeans.我需要使用 OpenWebBeans 迁移到 jakarta 命名空间。 Any help would be highly appreciated.任何帮助将不胜感激。
I am required to migrate to the jakarta namespace using OpenWebBeans.我需要使用 OpenWebBeans 迁移到 jakarta 命名空间。
They do have a Jakartified version since 2.0.15 .自 2.0.15 以来,他们确实有Jakartified版本。 Simply add <classifier>jakarta</classifier>
to the dependency.只需将<classifier>jakarta</classifier>
添加到依赖项中。
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf</artifactId>
<version>2.0.21</version>
<classifier>jakarta</classifier>
</dependency>
It has currently however only one problem: its four transitive dependencies web
, el22
, impl
and spi
are incorrectly not the Jakartified variants.然而,它目前只有一个问题:它的四个传递依赖web
、 el22
、 impl
和spi
错误地不是Jakartified 变体。 So you need to explicitly exclude them and explicitly include the Jakartified variants.因此,您需要明确排除它们并明确包含 Jakartified 变体。 So you're forced to end up with this monster graph:所以你不得不最终得到这个怪物图:
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf</artifactId>
<version>2.0.21</version>
<classifier>jakarta</classifier>
<exclusions>
<exclusion>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-el22</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-web</artifactId>
<version>2.0.21</version>
<classifier>jakarta</classifier>
<exclusions>
<exclusion>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-el22</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-el22</artifactId>
<version>2.0.21</version>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
<version>2.0.21</version>
<classifier>jakarta</classifier>
<exclusions>
<exclusion>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
<version>2.0.21</version>
<classifier>jakarta</classifier>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.