记一次tomcat7.0版本启动项目失败问题

时间:2021-11-13 02:52:14

测试项目在tomcat7中启动失败,报错如下:

@794314bc3
Error during job execution (jobs.Bootstrap) Oops: VerifyError
~ play.Logger.niceThrowable(Logger.java:) ~ play ~
play.exceptions.UnexpectedException: Unexpected Error
at play.Invoker$Invocation.onException(Invoker.java:)
at play.jobs.Job.onException(Job.java:)
at play.jobs.Job.call(Job.java:)
at Invocation.Job(Play!)
Caused by: java.lang.VerifyError: Expecting a stack map frame
Exception Details:
Location:
controllers/payment/PaymentBaseAction.check()V @: nop
Reason:
Expected stackmap frame at this location.
Bytecode:
: b804 1c00 b801 8c9a 8e03 bd00
: 6bb8 a700 c700 b1b8 b800 794b
: 152a b804 2ab6 009e 3c13
: 1bb8 041a 001b aa00
: 007f
: 008b 2a4d 014e 2c13 02a2
: a413 02a6 b802 aac0 004f 4e2d b800
: 003e 2a4d 033e 2c13 02ab ac13
: 02ae b802 b0c0 b602 b33e 1d99
: 2a4d 014e 2c13 02b4 b513 02b7 b802
00000a0: b9c0 004f 4e2d b800 b800 acb8
00000b0: 00af a700 1bb8 00b2 a700 15b8 00b5 a700
00000c0: 0fb8 00b8 a700 09b8 00bb a700 03a7 000e
00000d0: 3a06 013a 05b8 041e bf01 3a05 b804
00000e0: 20b1
Exception Handler Table:
bci [, ] => handler:
Stackmap Table:
same_frame(@)
append_frame(@,Object[#])
chop_frame(@,)
same_frame(@)
same_frame(@)
same_frame(@)
same_frame(@)
same_frame(@)
same_locals_1_stack_item_frame(@,Object[#])
same_frame(@) at payment.PaymentProxy.init(PaymentProxy.java:)
at jobs.Bootstrap.initPayment(Bootstrap.java:)
at jobs.Bootstrap.doJob(Bootstrap.java:)
at play.jobs.Job.doJobWithResult(Job.java:)
at play.jobs.Job.call(Job.java:)
... more

原因:

jvm验证时出了错误:显示字节码错误: 
网上的解释是因为引入版本为51的字节码规范,使用了严格的类型检查器,任何工具修改了字节码的,都需要更新stackmap,但是jws修改了字节码,而没有更新 stackmap使用了即java的新特性,所以使用较高的版本进行编译时就会报这个错。

解决办法

在tomcat 7启动文件中或者系统环境变量中加入

export JAVA_OPTS=-XX:-UseSplitVerifier

在tomcat 8启动文件中或者系统环境变量中加入

export JAVA_OPTS=-noverify

tomcat 7 参数优化实例

JAVA_OPTS='-server
-Xms2048m
-Xmx2048m
-Xss512k
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:+AggressiveOpts
-XX:+UseBiasedLocking
-XX:+DisableExplicitGC
-XX:+UseConcMarkSweepGC
-XX:+UseFastAccessorMethods
-XX:+CMSParallelRemarkEnabled
-XX:+UseCMSCompactAtFullCollection
-XX:+UseCMSInitiatingOccupancyOnly
-XX:-UseSplitVerifier'

附:在tomcat 8 ,JDK 1.8中,以上有些参数已被忽略或弃用,如下:

PermSize  忽略

MaxPermSize  忽略

UseCMSCompactAtFullCollection  弃用

- xx:ParallelGCThreads = N  如果处理器的数量预计将增加,那么你应该配置并行GC线程的数量来适当使用,N=处理器的个数

具体实例信息

[root@mytest ~]# /opt/apache-tomcat-8.5./bin/catalina.sh stop
Using CATALINA_BASE: /opt/apache-tomcat-8.5.
Using CATALINA_HOME: /opt/apache-tomcat-8.5.
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5./temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-8.5./bin/bootstrap.jar:/opt/apache-tomcat-8.5./bin/tomcat-juli.jar
OpenJDK -Bit Server VM warning: ignoring option PermSize=64m; support was removed in 8.0
OpenJDK -Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
OpenJDK -Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
OpenJDK -Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel
GC threads appropriately using -XX:ParallelGCThreads=N