迁移tomcat10 XXX cannot be cast to jakarta.servlet.Filter 解决方案

之前公司有个老项目(struts2+ibatis)的要升级到迁移tomcat10,结果死活无法起来。

看来下日志 报错都是 XXX cannot be cast to jakarta.servlet.Filter,搜了半天终于整出了解决方案。

报错原因是坑爹的tomcat10把javax.servlet-api名叫jaraka.servlet了(这不是蛋疼吗!!!)

解决方案有俩

1.修改代码,手动把包引用从 Javax.XXX改成 Jaraka.XXX 然后编译

2.使用apache官网提供的迁移工具 tomcat-jakartaee-migration 对编译后的项目处理一下,具体使用可以去看下项目的描述,一行命令就可以执行了。

这里提供一个现成的下载

具体使用方法:

如果是linux系统,进入bin目录,bash migrate.sh 旧项目(支持文件夹和war包) 生成的新项目(支持文件夹和war包),例如 bash migrate.sh old.war new.war。

如果是window系统,进入lib目录, java -jar jakartaee-migration-1.0.0.jar old new,跟上面差不多,脚本里就是执行的jakartaee-migration-1.0.0.jar。

ps:如果还不能启动,看看原本项目中pom.xml的javax.servlet-api依赖范围scope是否改成了provided,如果没有还是会有那个报错哦。

HostHatch 独立日优惠

因为Chia币的影响,储存机型都普遍涨价了,但这次普遍流量都给的很多,特别是nvme机。

两年付的性价比依旧可以的,购买方法:

1.注册账号存入资金 https://hosthatch.com/a?id=1837

2.点击下列的购买链接下单(要先预存余额才能购买),如果是两年付,需要额外发送工单获取两年付的特惠.

Storage (only available in Chicago – and very limited quantity):

1x 2.4+ GHz
512 MB RAM
250 GB disk
1 TB bandwidth
$15 per year
Pay for two years (+$7) – get doubled RAM and +9 TB free bandwidth
https://manage.hosthatch.com/billing/order/chi-250g-storage
1x 2.4+ GHz
1 GB RAM
1 TB usable storage
3 TB bandwidth
$40 per year
Chicago
Pay for two years – get doubled RAM and +20 TB free bandwidth
https://manage.hosthatch.com/billing/order/chi-1tb-storage/


NVMe plans (Europe – Amsterdam, Stockholm, Zurich, Oslo, Vienna, Warsaw, London, Madrid and Milan)

1 CPU core (12.5% dedicated, burstable up to 100%)
1 GB RAM
10 GB RAID-10 NVMe
1 TB bandwidth
$15 per year
Pay for two years – get doubled RAM, storage, and +5 TB free bandwidth
https://manage.hosthatch.com/billing/order/nvme1-ams
https://manage.hosthatch.com/billing/order/nvme1-sto
https://manage.hosthatch.com/billing/order/nvme1-zrh
https://manage.hosthatch.com/billing/order/nvme1-osl
https://manage.hosthatch.com/billing/order/nvme1-vie
https://manage.hosthatch.com/billing/order/nvme1-waw
https://manage.hosthatch.com/billing/order/nvme1-lon
https://manage.hosthatch.com/billing/order/nvme1-mad
https://manage.hosthatch.com/billing/order/nvme1-mil
2 CPU cores (50% dedicated, burstable up to 200%)
4 GB RAM
20 GB NVMe SSD
5 TB bandwidth
$30 per year
Pay for two years – get doubled RAM, storage, and +15 TB free bandwidth
https://manage.hosthatch.com/billing/order/nvme4-ams
https://manage.hosthatch.com/billing/order/nvme4-sto
https://manage.hosthatch.com/billing/order/nvme4-zrh
https://manage.hosthatch.com/billing/order/nvme4-osl
https://manage.hosthatch.com/billing/order/nvme4-vie
https://manage.hosthatch.com/billing/order/nvme4-waw
https://manage.hosthatch.com/billing/order/nvme4-lon
https://manage.hosthatch.com/billing/order/nvme4-mad
https://manage.hosthatch.com/billing/order/nvme4-mil
3 CPU cores (100% dedicated, burstable up to 300%)
8 GB RAM
40 GB NVMe SSD
10 TB bandwidth
$60 per year
Pay for two years – get doubled RAM, storage, and +20 TB free bandwidth
https://manage.hosthatch.com/billing/order/nvme8-ams
https://manage.hosthatch.com/billing/order/nvme8-sto
https://manage.hosthatch.com/billing/order/nvme8-zrh
https://manage.hosthatch.com/billing/order/nvme8-osl
https://manage.hosthatch.com/billing/order/nvme8-vie
https://manage.hosthatch.com/billing/order/nvme8-waw
https://manage.hosthatch.com/billing/order/nvme8-lon
https://manage.hosthatch.com/billing/order/nvme8-mad
https://manage.hosthatch.com/billing/order/nvme8-mil


NVMe plans (North America – Los Angeles, Chicago and New York):

1 CPU core (12.5% dedicated, burstable up to 100%)
1 GB RAM
10 GB RAID-10 NVMe
1 TB bandwidth
$15 per year
Pay for two years – get doubled RAM, storage, and +5 TB free bandwidth
https://manage.hosthatch.com/billing/order/nvme1-lax
https://manage.hosthatch.com/billing/order/nvme1-ny
https://manage.hosthatch.com/billing/order/nvme1-chi
2 CPU cores (50% dedicated, burstable up to 200%)
4 GB RAM
20 GB NVMe SSD
5 TB bandwidth
$30 per year
Pay for two years – get doubled RAM, storage, and +15 TB free bandwidth
https://manage.hosthatch.com/billing/order/nvme4-lax
https://manage.hosthatch.com/billing/order/nvme4-ny
https://manage.hosthatch.com/billing/order/nvme4-chi
3 CPU cores (100% dedicated, burstable up to 300%)
8 GB RAM
40 GB NVMe SSD
10 TB bandwidth
$60 per year
https://manage.hosthatch.com/billing/order/ams-16g-nvme
Pay for two years – get doubled RAM, storage, and +20 TB free bandwidth
https://manage.hosthatch.com/billing/order/nvme8-lax
https://manage.hosthatch.com/billing/order/nvme8-ny
https://manage.hosthatch.com/billing/order/nvme8-chi


NVMe plans (APAC – Hong Kong and Sydney):

1 CPU core (12.5% dedicated, burstable up to 100%)
1 GB RAM
10 GB RAID-10 NVMe
500 GB bandwidth
$15 per year
Pay for two years – get doubled RAM, storage, and bandwidth
https://manage.hosthatch.com/billing/order/nvme1-hkg
https://manage.hosthatch.com/billing/order/nvme1-syd
2 CPU cores (50% dedicated, burstable up to 200%)
4 GB RAM
20 GB NVMe SSD
1 TB bandwidth
$35 per year
Pay for two years – get doubled RAM, storage, and bandwidth
https://manage.hosthatch.com/billing/order/nvme4-hkg
https://manage.hosthatch.com/billing/order/nvme4-syd
3 CPU cores (100% dedicated, burstable up to 300%)
8 GB RAM
40 GB NVMe SSD
2 TB bandwidth
$65 per year
Pay for two years – get doubled RAM, storage, and bandwidth
https://manage.hosthatch.com/billing/order/nvme8-hkg
https://manage.hosthatch.com/billing/order/nvme8-syd


Bundles:

Choose any 7 locations, 1 VM per location:

1 CPU core (12.5% dedicated, burstable up to 100%)
1 GB RAM
10 GB RAID-10 NVMe
1 TB bandwidth
$65 per year

To order, login to your account with us, top up the credit, and open a sales ticket with the 7 locations of your choosing.
All locations bundle, 1 VM per location:

1 CPU core (12.5% dedicated, burstable up to 100%)
1 GB RAM
10 GB RAID-10 NVMe
1 TB bandwidth
$110 per year

To order, login to your account with us, top up the credit, and open a sales ticket.