TomEE upgrade from 8.0.13 to 9.0.0 spring application : Caused by: java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TryCatchFinally

huangapple go评论90阅读模式
英文:

TomEE upgrade from 8.0.13 to 9.0.0 spring application : Caused by: java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TryCatchFinally

问题

我们遇到了一个安全事件,需要将TomEE从8.0.13更新到9.0.0。更新后,我们无法启动应用程序,我们使用基于Spring的应用程序,但我们的构建过程有点问题。我们正在构建war文件,然后将该war文件部署到TomEE服务器(9.0.0)。

请查看我的pom.xml,有谁能帮我解决这个问题?

TomEE日志:

Caused by: java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TryCatchFinally
...

期望是应该无错误地运行。

英文:

We got a security incident to update TomEE from 8.0.13 to 9.0.0. After updating we couldn't able to start our application, we are using spring based application but our build process it something, we are building war file and this war file will be deployed to TomEE server(9.0.0).

Please find my pom.xml below, can anyone help me in resolving this?

<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&quot;>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
<relativePath />
</parent>
<groupId>com.company</groupId>
<artifactId>myapplication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myapplication</name>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.1</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
<dependency>
<groupId>net.sf.flexjson</groupId>
<artifactId>flexjson</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!--new Changes for client change -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!--new Changes for client upload file -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.14</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!--new Changes for client upload file -->

	&lt;!--new Changes for client change --&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.json&lt;/groupId&gt;
		&lt;artifactId&gt;json&lt;/artifactId&gt;
		&lt;version&gt;20220924&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;com.sa&lt;/groupId&gt;
		&lt;artifactId&gt;edx_api&lt;/artifactId&gt;
		&lt;version&gt;2.2.4&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;!-- START Flexlm license dependencies --&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;com.macrovision&lt;/groupId&gt;
		&lt;artifactId&gt;flexlm&lt;/artifactId&gt;
		&lt;version&gt;1.0&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;com.macrovision&lt;/groupId&gt;
		&lt;artifactId&gt;EccpressoAll&lt;/artifactId&gt;
		&lt;version&gt;1.0&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;com.macrovision&lt;/groupId&gt;
		&lt;artifactId&gt;flexlmmgmt&lt;/artifactId&gt;
		&lt;version&gt;1.0&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;com.macrovision&lt;/groupId&gt;
		&lt;artifactId&gt;flexlmutil&lt;/artifactId&gt;
		&lt;version&gt;1.0&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;!-- END Flexlm license dependencies --&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		&lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
		&lt;exclusions&gt;
			&lt;exclusion&gt;
				&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
				&lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt;
			&lt;/exclusion&gt;
		&lt;/exclusions&gt;
	&lt;/dependency&gt;

	&lt;dependency&gt;
		&lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
		&lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
		&lt;scope&gt;provided&lt;/scope&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;javax.servlet&lt;/groupId&gt;
		&lt;artifactId&gt;jstl&lt;/artifactId&gt;
	&lt;/dependency&gt;
	&lt;!-- New changes event bus --&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
		&lt;artifactId&gt;activemq-core&lt;/artifactId&gt;
		&lt;version&gt;5.7.0&lt;/version&gt;
	&lt;/dependency&gt;
	&lt;dependency&gt;
		&lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
		&lt;artifactId&gt;activemq-broker&lt;/artifactId&gt;
		&lt;version&gt;5.17.4&lt;/version&gt;&lt;!--$NO-MVN-MAN-VER$--&gt;
	&lt;/dependency&gt;

&lt;/dependencies&gt;
&lt;build&gt;
	&lt;finalName&gt;MyApplication&lt;/finalName&gt;
	&lt;plugins&gt;
		&lt;plugin&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
		&lt;/plugin&gt;
	&lt;/plugins&gt;
&lt;/build&gt;

</project>


&gt;  Caused by: java.lang.NoClassDefFoundError:
&gt; javax/servlet/jsp/tagext/TryCatchFinally
&gt;                 at java.base/java.lang.ClassLoader.defineClass1(Native Method)
&gt;                 at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
&gt;                 at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
&gt;                 at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:512)
&gt;                 at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:420)
&gt;                 at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:414)
&gt;                 at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
&gt;                 at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:413)
&gt;                 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:586)
&gt;                 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
&gt;                 at java.base/java.lang.ClassLoader.defineClass1(Native Method)
&gt;                 at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
&gt;                 at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
&gt;                 at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:512)
&gt;                 at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:420)
&gt;                 at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:414)
&gt;                 at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
&gt;                 at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:413)
&gt;                 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:586)
&gt;                 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:573)
&gt;                 at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:222)
&gt;                 at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:83)
&gt;                 at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:2371)
&gt;                 at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:2019)```
Expectation is it should run without any errors.
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;parent&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
&lt;version&gt;2.5.6&lt;/version&gt;
&lt;relativePath /&gt;
&lt;/parent&gt;
&lt;groupId&gt;com.company&lt;/groupId&gt;
&lt;artifactId&gt;myApplication&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;name&gt;myApplication&lt;/name&gt;
&lt;packaging&gt;war&lt;/packaging&gt;
&lt;properties&gt;
&lt;java.version&gt;1.8&lt;/java.version&gt;
&lt;/properties&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
&lt;artifactId&gt;poi&lt;/artifactId&gt;
&lt;version&gt;5.2.3&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
&lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
&lt;version&gt;5.2.3&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.opencsv&lt;/groupId&gt;
&lt;artifactId&gt;opencsv&lt;/artifactId&gt;
&lt;version&gt;5.7.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;jakarta.xml.bind&lt;/groupId&gt;
&lt;artifactId&gt;jakarta.xml.bind-api&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
&lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
&lt;version&gt;2.3.8&lt;/version&gt;
&lt;scope&gt;runtime&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.google.guava&lt;/groupId&gt;
&lt;artifactId&gt;guava&lt;/artifactId&gt;
&lt;version&gt;31.1-jre&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;net.sf.flexjson&lt;/groupId&gt;
&lt;artifactId&gt;flexjson&lt;/artifactId&gt;
&lt;version&gt;3.3&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
&lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;!--new Changes for client change --&gt;
&lt;dependency&gt;
&lt;groupId&gt;javax.ws.rs&lt;/groupId&gt;
&lt;artifactId&gt;javax.ws.rs-api&lt;/artifactId&gt;
&lt;version&gt;2.1.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
&lt;artifactId&gt;httpclient&lt;/artifactId&gt;
&lt;version&gt;4.5.14&lt;/version&gt;&lt;!--$NO-MVN-MAN-VER$--&gt;
&lt;/dependency&gt;
&lt;!--new Changes for client upload file --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
&lt;artifactId&gt;httpmime&lt;/artifactId&gt;
&lt;version&gt;4.5.14&lt;/version&gt;&lt;!--$NO-MVN-MAN-VER$--&gt;
&lt;/dependency&gt;
&lt;!--new Changes for client upload file --&gt;
&lt;!--new Changes for client change --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.json&lt;/groupId&gt;
&lt;artifactId&gt;json&lt;/artifactId&gt;
&lt;version&gt;20220924&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.sa&lt;/groupId&gt;
&lt;artifactId&gt;edx_api&lt;/artifactId&gt;
&lt;version&gt;2.2.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- START Flexlm license dependencies --&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.macrovision&lt;/groupId&gt;
&lt;artifactId&gt;flexlm&lt;/artifactId&gt;
&lt;version&gt;1.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.macrovision&lt;/groupId&gt;
&lt;artifactId&gt;EccpressoAll&lt;/artifactId&gt;
&lt;version&gt;1.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.macrovision&lt;/groupId&gt;
&lt;artifactId&gt;flexlmmgmt&lt;/artifactId&gt;
&lt;version&gt;1.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.macrovision&lt;/groupId&gt;
&lt;artifactId&gt;flexlmutil&lt;/artifactId&gt;
&lt;version&gt;1.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- END Flexlm license dependencies --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
&lt;exclusions&gt;
&lt;exclusion&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt;
&lt;/exclusion&gt;
&lt;/exclusions&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
&lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;javax.servlet&lt;/groupId&gt;
&lt;artifactId&gt;jstl&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;!-- New changes event bus --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
&lt;artifactId&gt;activemq-core&lt;/artifactId&gt;
&lt;version&gt;5.7.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
&lt;artifactId&gt;activemq-broker&lt;/artifactId&gt;
&lt;version&gt;5.17.4&lt;/version&gt;&lt;!--$NO-MVN-MAN-VER$--&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
&lt;artifactId&gt;javax.servlet.jsp-api&lt;/artifactId&gt;
&lt;version&gt;2.3.3&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;build&gt;
&lt;finalName&gt;MyApplication&lt;/finalName&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
&lt;/project&gt;
</details>
# 答案1
**得分**: 2
TomEE 9 仅支持 Jakarta 命名空间(EE 9.1),无法与 Javax 命名空间一起使用。
您需要坚持使用 EE8(即 TomEE 8.0.x),或迁移您的应用程序及其依赖项到 Jakarta 命名空间。在 TomEE 9 中添加 javax 依赖项将无法工作。
<details>
<summary>英文:</summary>
TomEE 9 supports the Jakarta namespace (EE 9.1) only and won&#39;t work with the Javax Namespace.
You need to stick with EE8 (= TomEe 8.0.x) or migrate your app and its dependencies to the Jakarta namespace. Adding javax dependencies to TomEE 9 won&#39;t work.
</details>
# 答案2
**得分**: 1
Tomee 9基于Tomcat 10,而*javax.servlet*等包已经重命名为*jakarta.servlet*,导致您的应用程序(以及第三方库)依赖于javax.servlet包。为了简化迁移,Tomcat提供了一个工具,可以为您转换应用程序及其依赖项。
从Tomcat 10迁移指南:
https://tomcat.apache.org/migration-10.html
&gt; Tomcat可以在部署时使用Apache Tomcat Jakarta EE迁移工具将现有的Web应用程序从Java EE 8转换为Jakarta EE 9。要使用此功能,Web应用程序应放置在Host legacyAppBase文件夹中(默认名为webapps-javaee),它们将被转换为Host appBase文件夹中的等效Jakarta EE Web应用程序(默认名为webapps)。
&gt; 或者,也可以提前使用Apache Tomcat Jakarta EE迁移工具或任何类似的转换工具,以获得更快的部署时间和更精确的转换配置选项。
在我的情况下,我正在使用pom文件中的Ant任务运行该工具:
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
&lt;!-- 是的,这是一个很旧的版本 --&gt;
&lt;version&gt;1.8&lt;/version&gt;
&lt;dependencies&gt;
&lt;!-- https://mvnrepository.com/artifact/org.apache.tomcat/jakartaee-migration --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
&lt;artifactId&gt;jakartaee-migration&lt;/artifactId&gt;
&lt;version&gt;1.0.7&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;javax2jakarta&lt;/id&gt;
&lt;phase&gt;package&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;run&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;target&gt;
&lt;taskdef name=&quot;javax2jakarta&quot;
classname=&quot;org.apache.tomcat.jakartaee.MigrationTask&quot;
classpath=&quot;jakartaee-migration-*-shaded.jar&quot; /&gt;
&lt;javax2jakarta
src=&quot;${project.build.directory}/${project.build.finalName}.war&quot;
dest=&quot;${project.build.directory}/tomee9/${project.build.finalName}.war&quot;
profile=&quot;tomcat&quot; /&gt;
&lt;/target&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;
如果您不需要两个WAR文件(一个与Tomee 8兼容,另一个与Tomee 9兼容),可以在*package*之前直接在构建文件夹上运行插件:`src=${project.build.directory}/${project.build.finalName}`
**注意**:在我的情况下,它解决了对javax.servlet.*类的NoClassDefFoundError / ClassNotFoundException问题,但目前我仍然面临关于Spring 5使用的问题。
<details>
<summary>英文:</summary>
Tomee 9 is based on Tomcat 10 and packages like *javax.servlet* have been renamed to *jakarta.servlet* breaking your application (and third party libraries) dependency to javax.servlet package. 
To ease the migration,Tomcat provides a tool to convert your application and its dependencies for you.
From Tomcat 10 migration guide:
https://tomcat.apache.org/migration-10.html
&gt; Tomcat can convert an existing web application from Java EE 8 to
&gt; Jakarta EE 9 at deployment time using the Apache Tomcat migration tool
&gt; for Jakarta EE. To make use of the feature, the web application should
&gt; be placed in the Host legacyAppBase folder (by default named
&gt; webapps-javaee) and they will be converted to an equivalent Jakarta EE
&gt; web application in the Host appBase folder (by default named webapps).
&gt; 
&gt; Alternately, the Apache Tomcat migration tool for Jakarta EE or any
&gt; similar conversion tool can be used ahead of time to benefit from
&gt; faster deployment time and more precise conversion configuration
&gt; options.
&gt; 
In my case I&#39;m running the tool using the Ant task from my pom file:
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
&lt;!-- Yes it is a very old version --&gt;
&lt;version&gt;1.8&lt;/version&gt;
&lt;dependencies&gt;
&lt;!-- https://mvnrepository.com/artifact/org.apache.tomcat/jakartaee-migration --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
&lt;artifactId&gt;jakartaee-migration&lt;/artifactId&gt;
&lt;version&gt;1.0.7&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;javax2jakarta&lt;/id&gt;
&lt;phase&gt;package&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;run&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;target&gt;
&lt;taskdef name=&quot;javax2jakarta&quot;
classname=&quot;org.apache.tomcat.jakartaee.MigrationTask&quot;
classpath=&quot;jakartaee-migration-*-shaded.jar&quot; /&gt;
&lt;javax2jakarta
src=&quot;${project.build.directory}/${project.build.finalName}.war&quot;
dest=&quot;${project.build.directory}/tomee9/${project.build.finalName}.war&quot;
profile=&quot;tomcat&quot; /&gt;
&lt;/target&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;
If you don&#39;t need two wars files (one compatible with Tomee 8 and and the other with Tomee 9) you can run the plugin in a phase before *package* directly on the build folder : `src=${project.build.directory}/${project.build.finalName}`
**Note**: In my case it solved NoClassDefFoundError / ClassNotFoundException issue for javax.servlet.* classes but at the moment I&#39;m still facing issues regarding Spring 5 usage. 
</details>
# 答案3
**得分**: 0
你试过添加这个依赖吗?
[https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api/2.3.3](https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api/2.3.3)
```xml
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>

不要忘记运行 mvn clean install 或者你喜欢的其他命令来拉取项目的依赖。

英文:

Have you tried adding this dependency

https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api/2.3.3

&lt;!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api --&gt;
&lt;dependency&gt;
&lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
&lt;artifactId&gt;javax.servlet.jsp-api&lt;/artifactId&gt;
&lt;version&gt;2.3.3&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;

Don't forget to run mvn clean install or whatever you like to pull your dependencies for your project

huangapple
  • 本文由 发表于 2023年3月9日 13:13:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75680662.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定