测试项目在tomcat7中启动失败,报错如下:
@794314bc3 Error during job execution (jobs.Bootstrap) Oops: VerifyError ~ play.Logger.niceThrowable(Logger.java:570) ~ play ~ 35845 play.exceptions.UnexpectedException: Unexpected Error at play.Invoker$Invocation.onException(Invoker.java:244) at play.jobs.Job.onException(Job.java:124) at play.jobs.Job.call(Job.java:163) at Invocation.Job(Play!) Caused by: java.lang.VerifyError: Expecting a stack map frame Exception Details: Location: controllers/payment/PaymentBaseAction.check()V @23: nop Reason: Expected stackmap frame at this location. Bytecode: 0000000: b804 1c00 b801 8c9a 0012 1301 8e03 bd00 0000010: 6bb8 0190 a700 c700 b1b8 0192 b800 794b 0000020: 1304 152a b804 1700 2ab6 009e 3c13 0418 0000030: 1bb8 041a 001b aa00 0000 0097 0000 0000 0000040: 0000 0004 0000 0022 0000 007f 0000 0085 0000050: 0000 008b 0000 0091 2a4d 014e 2c13 02a2 0000060: 1302 a413 02a6 b802 aac0 004f 4e2d b800 0000070: 4999 003e 2a4d 033e 2c13 02ab 1302 ac13 0000080: 02ae b802 b0c0 0141 b602 b33e 1d99 0022 0000090: 2a4d 014e 2c13 02b4 1302 b513 02b7 b802 00000a0: b9c0 004f 4e2d b800 2299 0006 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 1906 bf01 3a05 b804 00000e0: 20b1 Exception Handler Table: bci [0, 208] => handler: 208 Stackmap Table: same_frame(@25) append_frame(@88,Object[#122]) chop_frame(@175,1) same_frame(@181) same_frame(@187) same_frame(@193) same_frame(@199) same_frame(@205) same_locals_1_stack_item_frame(@208,Object[#978]) same_frame(@219) at payment.PaymentProxy.init(PaymentProxy.java:60) at jobs.Bootstrap.initPayment(Bootstrap.java:64) at jobs.Bootstrap.doJob(Bootstrap.java:54) at play.jobs.Job.doJobWithResult(Job.java:50) at play.jobs.Job.call(Job.java:146) ... 1 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.33/bin/catalina.sh stop Using CATALINA_BASE: /opt/apache-tomcat-8.5.33 Using CATALINA_HOME: /opt/apache-tomcat-8.5.33 Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.33/temp Using JRE_HOME: /usr Using CLASSPATH: /opt/apache-tomcat-8.5.33/bin/bootstrap.jar:/opt/apache-tomcat-8.5.33/bin/tomcat-juli.jar OpenJDK 64-Bit Server VM warning: ignoring option PermSize=64m; support was removed in 8.0 OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0 OpenJDK 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release. OpenJDK 64-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