記一次tomcat7.0版本啟動項目失敗問題


測試項目在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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM