Eclipse下启动Tomcat报JVM错误详解

java Web服务器 November 22 2012


报错机器环境:操作系统:windows XP SP3IDE:基于eclipse的STS(SpringSource Tool Suite Version: 2.8.0.RELEASE)JDK:1.6.0_26服务器:Tomcat v7.0启动tomcat时报错误提示,请查看错误日志:D:\sts-2.8.0.RELEASE\hs_err_pid4868.log———————————————–日志开始## A fatal error has been detected by the Java Runtime Environment:## Internal Error (c1_Optimizer.cpp:271), pid=4868, tid=836# guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp## JRE version: 6.0_26-b03# Java VM: Java HotSpot(TM) Client VM (20.1-b02 mixed mode, sharing windows-x86 )# If you would like to submit a bug report, please visit:# http://java.sun.com/webapps/bugreport/crash.jsp#————— T H R E A D —————Current thread (0x02ba4800): JavaThread “C1 CompilerThread0” daemon [_thread_in_native, id=836, stack(0x02dd0000,0x02e20000)]Stack: [0x02dd0000,0x02e20000], sp=0x02e1f470, free space=317kNative frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)V [jvm.dll+0x13379a]V [jvm.dll+0x12e65c]V [jvm.dll+0x2054c2]V [jvm.dll+0x206196]V [jvm.dll+0x1f0397]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f03e6]V [jvm.dll+0x1f08eb]V [jvm.dll+0x204bd0]V [jvm.dll+0x204c91]V [jvm.dll+0x1f11da]V [jvm.dll+0x1e345e]V [jvm.dll+0x1e3a65]V [jvm.dll+0x1e3b6c]V [jvm.dll+0x1e3cbf]V [jvm.dll+0x1e3f14]V [jvm.dll+0x3db2d]V [jvm.dll+0x3e655]V [jvm.dll+0x1190d4]V [jvm.dll+0x1411ac]C [msvcr71.dll+0x9565] endthreadex+0xa0C [kernel32.dll+0xb729] GetModuleFileNameA+0x1baCurrent CompileTask:C1: 5952 1282 org.hibernate.cfg.annotations.SimpleValueBinder.setType(Lorg/hibernate/annotations/common/reflection/XProperty;Lorg/hibernate/annotations/common/reflection/XClass;)V (921 bytes)————— P R O C E S S —————Java Threads: ( => current thread )0x03236000 JavaThread “Thread-2” daemon [_thread_in_native, id=4920, stack(0x035a0000,0x035f0000)]0x030c5400 JavaThread “GC Daemon” daemon [_thread_blocked, id=5788, stack(0x034c0000,0x03510000)]0x02bab400 JavaThread “Low Memory Detector” daemon [_thread_blocked, id=3156, stack(0x02e20000,0x02e70000)]=>0x02ba4800 JavaThread “C1 CompilerThread0” daemon [_thread_in_native, id=836, stack(0x02dd0000,0x02e20000)]0x02ba3000 JavaThread “Attach Listener” daemon [_thread_blocked, id=5104, stack(0x02d80000,0x02dd0000)]0x02bc1800 JavaThread “Signal Dispatcher” daemon [_thread_blocked, id=864, stack(0x02d30000,0x02d80000)]0x02b9b800 JavaThread “Finalizer” daemon [_thread_blocked, id=3252, stack(0x02ce0000,0x02d30000)]0x02b96c00 JavaThread “Reference Handler” daemon [_thread_blocked, id=940, stack(0x02c90000,0x02ce0000)]0x00847000 JavaThread “main” [_thread_blocked, id=2132, stack(0x008e0000,0x00930000)]Other Threads:0x02b5ac00 VMThread [stack: 0x02c40000,0x02c90000] [id=5408]0x02bc2400 WatcherThread [stack: 0x02e70000,0x02ec0000] [id=4112]VM state:not at safepoint (normal execution)VM Mutex/Monitor currently owned by a thread: NoneHeapdef new generation total 5376K, used 985K [0x229e0000, 0x22fb0000, 0x27f30000)eden space 4800K, 14% used [0x229e0000, 0x22a8ed00, 0x22e90000)from space 576K, 49% used [0x22e90000, 0x22ed7a18, 0x22f20000)to space 576K, 0% used [0x22f20000, 0x22f20000, 0x22fb0000)tenured generation total 11784K, used 9849K [0x27f30000, 0x28ab2000, 0x329e0000)the space 11784K, 83% used [0x27f30000, 0x288ce7f0, 0x288ce800, 0x28ab2000)compacting perm gen total 17408K, used 17293K [0x329e0000, 0x33ae0000, 0x369e0000)the space 17408K, 99% used [0x329e0000, 0x33ac3738, 0x33ac3800, 0x33ae0000)ro space 10240K, 51% used [0x369e0000, 0x36f0dff8, 0x36f0e000, 0x373e0000)rw space 12288K, 55% used [0x373e0000, 0x37a7c208, 0x37a7c400, 0x37fe0000)Code Cache [0x00960000, 0x00c90000, 0x02960000)total_blobs=1486 nmethods=1311 adapters=110 free_code_cache=30227648 largest_free_block=256Dynamic libraries:0x00400000 - 0x00424000 D:\Java\jre6\bin\javaw.exe0x7c920000 - 0x7c9b6000 C:\WINDOWS\system32\ntdll.dll0x7c800000 - 0x7c91e000 C:\WINDOWS\system32\kernel32.dll0x77da0000 - 0x77e49000 C:\WINDOWS\system32\ADVAPI32.dll0x77e50000 - 0x77ee2000 C:\WINDOWS\system32\RPCRT4.dll0x77fc0000 - 0x77fd1000 C:\WINDOWS\system32\Secur32.dll0x77d10000 - 0x77da0000 C:\WINDOWS\system32\USER32.dll0x77ef0000 - 0x77f39000 C:\WINDOWS\system32\GDI32.dll0x76300000 - 0x7631d000 C:\WINDOWS\system32\IMM32.DLL0x62c20000 - 0x62c29000 C:\WINDOWS\system32\LPK.DLL0x73fa0000 - 0x7400b000 C:\WINDOWS\system32\USP10.dll0x7c340000 - 0x7c396000 D:\Java\jre6\bin\msvcr71.dll0x6d7f0000 - 0x6da9f000 D:\Java\jre6\bin\client\jvm.dll0x76b10000 - 0x76b3a000 C:\WINDOWS\system32\WINMM.dll0x5ce30000 - 0x5ce37000 C:\WINDOWS\system32\serwvdrv.dll0x5b0f0000 - 0x5b0f7000 C:\WINDOWS\system32\umdmxfrm.dll0x6d7a0000 - 0x6d7ac000 D:\Java\jre6\bin\verify.dll0x6d320000 - 0x6d33f000 D:\Java\jre6\bin\java.dll0x76bc0000 - 0x76bcb000 C:\WINDOWS\system32\PSAPI.DLL0x6d7e0000 - 0x6d7ef000 D:\Java\jre6\bin\zip.dll0x6d550000 - 0x6d559000 D:\Java\jre6\bin\management.dll0x6d780000 - 0x6d788000 D:\Java\jre6\bin\sunmscapi.dll0x765e0000 - 0x76673000 C:\WINDOWS\system32\CRYPT32.dll0x76db0000 - 0x76dc2000 C:\WINDOWS\system32\MSASN1.dll0x77be0000 - 0x77c38000 C:\WINDOWS\system32\msvcrt.dll0x6d600000 - 0x6d613000 D:\Java\jre6\bin\net.dll0x71a20000 - 0x71a37000 C:\WINDOWS\system32\WS2_32.dll0x71a10000 - 0x71a18000 C:\WINDOWS\system32\WS2HELP.dll0x719c0000 - 0x719fe000 C:\WINDOWS\system32\mswsock.dll0x60fd0000 - 0x61025000 C:\WINDOWS\system32\hnetcfg.dll0x71a00000 - 0x71a08000 C:\WINDOWS\System32\wshtcpip.dll0x68000000 - 0x68036000 C:\WINDOWS\system32\rsaenh.dll0x759d0000 - 0x75a7f000 C:\WINDOWS\system32\USERENV.dll0x5fdd0000 - 0x5fe25000 C:\WINDOWS\system32\netapi32.dll0x76ef0000 - 0x76f17000 C:\WINDOWS\system32\DNSAPI.dll0x76d30000 - 0x76d48000 C:\WINDOWS\system32\iphlpapi.dll0x76f80000 - 0x76f88000 C:\WINDOWS\System32\winrnr.dll0x76f30000 - 0x76f5c000 C:\WINDOWS\system32\WLDAP32.dll0x76f90000 - 0x76f96000 C:\WINDOWS\system32\rasadhlp.dllVM Arguments:jvm_args: -Dcatalina.base=F:\workspace-sts.metadata.plugins\org.eclipse.wst.server.core\tmp0 -Dcatalina.home=D:\apache-tomcat-7.0.21 -Dwtp.deploy=F:\workspace-sts.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps -Djava.endorsed.dirs=D:\apache-tomcat-7.0.21\endorsed -Dfile.encoding=UTF-8java_command: org.apache.catalina.startup.Bootstrap startLauncher Type: SUN_STANDARDEnvironment Variables:JAVA_HOME=D:\Java\jdk1.6.0_26CLASSPATH=.;D:\Java\jdk1.6.0_26\lib\dt.jar;D:\Java\jdk1.6.0_26\lib\tools.jar;PATH=D:/Java/jre6/bin/client;D:/Java/jre6/bin;D:/Java/jre6/lib/i386;D:\oracle11\product\11.1.0\db_2\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\SinoVoice\jTTS 5.0 Desktop\Bin;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\WINDOWS\system32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\program files\sybase\database\DLL;c:\program files\sybase\database\BIN;c:\Program Files\Sybase\Sybase Central\win32;c:\program files\sybase\database\ASEP;D:\Java\jdk1.6.0_26\bin;D:\Java\jdk1.6.0_26\jre\bin;D:\Program Files\MySQL\MySQL Server 5.5\bin;D:\apache-ant-1.8.2\bin;D:\sts-2.8.0.RELEASE;USERNAME=AdministratorOS=Windows_NTPROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel ————— S Y S T E M —————OS: Windows XP Build 2600 Service Pack 3CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 23 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3Memory: 4k page, physical 2086316k(137300k free), swap 4024588k(1656684k free)vm_info: Java HotSpot(TM) Client VM (20.1-b02) for windows-x86 JRE (1.6.0_26-b03), built on May 4 2011 00:50:59 by “java_re” with MS VC++ 7.1 (VS2003)time: Thu Nov 22 11:33:50 2012elapsed time: 5 seconds———————————————–日志结束大概是java虚拟机的一个BUG导致的,另外,从红色字体部分基本可以判断此错误与hibernate包有关,JVM在编译到hibernate的一个类中的方法时出现了问题org.hibernate.cfg.annotations.SimpleValueBinder.setType于是以此包全限定名作为关键字进行百度google,发现遇到过此类问题的人不少,然后进入官网查找到该JVM BUG信息:http://www.oracle.com/technetwork/java/javase/crashes-137240.html#gbyzd

方法一:

If the fatal error log indicates that the crash occurred in a compiler thread, then it is possible (but not always the case) that you have encountered a compiler bug. Similarly, if the crash is in compiled code then it is possible that the compiler has generated incorrect code._这个严重错误的日志显示,如果在编译器线程compiler thread中出现崩溃,则很可能(但不是绝对)你已遇到了一个编译器的BUG。同样地,如果是在已编译的代码中出现,则说明编译器生成了错误的代码。_Compiler Thread 与 Compiled Code,根据日志来看,我遇到的似乎属于Compiler Thread这类错误,这两种两者有什么区别?不懂,算了,在此不求甚解吧。In this case there are two potential workarounds:

  • The brute force approach: change the configuration so that the application is run with the -client option to specify the HotSpot Client VM.

  • Assume that the bug only occurs during the compilation of the setPriority method and exclude this method from compilation. 大概有两种解决方案:

  1. 暴力一点的方式:修改JVM的启动参数,加上选项“-client”,以保证应用程序能够以指定的HotSpot Client VM客户端虚拟机启动运行。

  2. 假设此BUG只出现在某个方法的编译期(官方举例用的是java.lang.Thread.setPriority,我这里是org.hibernate.cfg.annotations.SimpleValueBinder.setType),那么将此方法排除在编译之外即可。 据此可判断,我的报错似乎与第二种情况更接近,再看看官方给出的具体解决办法:The second approach (exclude the method from compilation) requires creating the file.hotspot_compiler in the working directory of the application. Below is an example of this file:exclude java/lang/Thread setPriority In general the format of this file is exclude CLASS METHOD, where CLASS is the class (fully qualified with the package name) and METHOD is the name of the method. Constructor methods are specified as  and static initializers are specified as 第二种方法(即将报错的方法从编译中排除)需要在应用程序的工作目录下创建一个文件,取名.hotspot_compile(注意:文件名前面带.点号),文件内容举例如下:```exclude java/lang/Thread setPriority ``` 对应到我的问题,应改为:```exclude org/hibernate/cfg/annotations/SimpleValueBinder setType ``` 当然,我这里报错的方法既不是构造方法,也不是静态方法,所以也别无其他特别注意之处,在此不论。但是文件.hotspot_compile所在的”应用程序的工作目录“到底是哪个,我尝试了许多个目录,都不正确,最后在eclipse中的tomcat配置界面中无意发现了working directory选项,如下图:[![](http://www.ichatter.cnuploads/2012/11/QQ截图20121122170254.png)](http://www.ichatter.cnuploads/2012/11/QQ截图20121122170254.png)于是把写好的.hotspot_compiler文件放入默认的”D:\sts-2.8.0.RELEASE“文件夹下,在eclipse中启动tomcat,OK。补充一下:在找这个”应用程序的工作目录“时,我们应该理解一点,不是我们要部署到tomcat中的web工程,而是指启动这个JVM的程序,显然我的eclipse工作目录是”D:\sts-2.8.0.RELEASE“。

方法二:

针对方法一中的配置方式,我在网上搜了另一种方法,即在eclipse的tomcat启动配置中加入启动参数,也与创建.hotspot_compile文件的方式实现了一样的效果,具体如下图:右击Tomcat实例,在菜单中点击open,打开tomcat配置界面,如下图:点击open launch configuration,打开编辑界面,选中第二个选项卡Arguments,如下图:在VM arguments一栏最后加入参数:-XX:CompileCommand=exclude,org/hibernate/cfg/annotations/SimpleValueBinder,setType点击OK,重启,正常。方法三:结合方法一与方法二,可以如下实现:1.首先创建一个文件,内容与方法一中的.hotspot_compiler文件完全一样,文件名可以相同也可以不同,比如:我给它取名abc.txt,保存在F:\盘,然后像方法二那样,在tomcat配置界面中给JVM加启动参数-XX:CompileCommandFile=F:\abc.txt如下图: 只有一点稍微注意:方法二中的参数名为-XX:CompileCommand,则在方法三中的参数名为-XX:CompileCommandFile。其他解决思路:1.本人另一个使用了hibernate新版本的web程序没有出现此BUG,也就是说,升级至最新版本hibernate的话,应该也可以解决JVM异常。2.既然是JVM的BUG,那么我们是否可以通过升级JDK到最新版本(目前Version 7 Update 9)来解决,本人实践证明了其可行性,所以,也相当值得推荐。

原文链接:http://ichatter.cn/eclipse-e4-b8-8b-e5-90-af-e5-8a-a8tomcat-e6-8a-a5jvm-e9-94-99-e8-af-af.html


欢迎来到阿J小虫的博客

Follow @ichatter on GitHub

最新评论

推荐内容