1. 程式人生 > >tomcat執行時異常“A fatal error has been detected by the Java Runtime Environment:”

tomcat執行時異常“A fatal error has been detected by the Java Runtime Environment:”

背景

 

tomcat跑好好的,突然崩了。上線看log發現提示如下異常。

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f580dd5aa91, pid=5252, tid=140016395622144
#
# JRE version: Java(TM) SE Runtime Environment (7.0_79-b15) (build 1.7.0_79-b15)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.79-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libresolv.so.2+0x7a91]  __libc_res_nquery+0x1c1
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
# An error report file with more information is saved as:
# /tomcat8/hs_err_pid8935.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

根據異常得知有個錯誤log。那我們就把這個log下載下來看看。上述為例log地址:/tomcat8/hs_err_pid8935.log

 

log關鍵部分內容

Stack: [0x00007f489251d000,0x00007f489261e000],  sp=0x00007f489261a2e0,  free space=1012k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libresolv.so.2+0x7a91]  __libc_res_nquery+0x1c1
C  [libresolv.so.2+0x7fd1]  __libc_res_nquerydomain+0xd1

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  java.net.Inet6AddressImpl.lookupAllHostAddr(Ljava/lang/String;)[Ljava/net/InetAddress;+0
j  java.net.InetAddress$2.lookupAllHostAddr(Ljava/lang/String;)[Ljava/net/InetAddress;+4
j  java.net.InetAddress.getAddressesFromNameService(Ljava/lang/String;Ljava/net/InetAddress;)[Ljava/net/InetAddress;+51
j  java.net.InetAddress.getAllByName0(Ljava/lang/String;Ljava/net/InetAddress;Z)[Ljava/net/InetAddress;+29
j  java.net.InetAddress.getAllByName(Ljava/lang/String;Ljava/net/InetAddress;)[Ljava/net/InetAddress;+383
j  java.net.InetAddress.getAllByName(Ljava/lang/String;)[Ljava/net/InetAddress;+2
j  java.net.InetAddress.getByName(Ljava/lang/String;)Ljava/net/InetAddress;+1
j  java.net.InetSocketAddress.<init>(Ljava/lang/String;I)V+15
j  sun.net.NetworkClient.doConnect(Ljava/lang/String;I)Ljava/net/Socket;+92
j  sun.net.www.http.HttpClient.openServer(Ljava/lang/String;I)V+4
j  sun.net.www.http.HttpClient.openServer()V+114
j  sun.net.www.protocol.https.HttpsClient.<init>(Ljavax/net/ssl/SSLSocketFactory;Ljava/net/URL;Ljava/net/Proxy;I)V+122
j  sun.net.www.protocol.https.HttpsClient.New(Ljavax/net/ssl/SSLSocketFactory;Ljava/net/URL;Ljavax/net/ssl/HostnameVerifier;Ljava/net/Proxy;ZILsun/net/www/protocol/http/HttpURLConnection;)Lsun/net/www/http/HttpClient;+355
j  sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Ljava/net/URL;Ljava/net/Proxy;I)Lsun/net/www/http/HttpClient;+13
j  sun.net.www.protocol.http.HttpURLConnection.plainConnect0()V+357
j  sun.net.www.protocol.http.HttpURLConnection.plainConnect()V+71
j  sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect()V+9
j  sun.net.www.protocol.https.HttpsURLConnectionImpl.connect()V+4

上述問題得知是host問題。

解決方案:在/etc/hosts中加入本機ip名與本機的主機名的對映即可。

獲取主機名指令

hostname

問題解決