Linux Environment C3p0 Failed to get the inetaddress for VMID solution __linux

Source: Internet
Author: User

Today in doing a Java project to use the C3P0 data source, the program runs under Windows without any problems, but to the server (Linux environment) when the deployment of the runtime abnormal, the exception information is as follows:

2014-08-19 20:51:01 [INFO] Failed to get local inetaddress for VMID. This is unlikely to matter. At all. 
	We ll add some extra randomness java.net.unknownhostexception:w: W at Java.net.InetAddress.getLocalHost (Unknown Source) At Com.mchange.v2.c3p0.impl.C3P0ImplUtils.generateVmId (c3p0implutils.java:120) at Com.mchange.v2.c3p0.impl.c3p0implutils.<clinit> (c3p0implutils.java:98) at Com.mchange.v2.c3p0.impl.poolbackeddatasourcebase.<init> (poolbackeddatasourcebase.java:227) at Com.mchange.v2.c3p0.impl.abstractpoolbackeddatasource.<init> (abstractpoolbackeddatasource.java:62) at Com.mchange.v2.c3p0.combopooleddatasource.<init> (combopooleddatasource.java:109) at
Com.mchange.v2.c3p0.combopooleddatasource.<init> (combopooleddatasource.java:105) ..... caused by:java.net.unknownhostexception:w at Java.net.Inet4AddressImpl.lookupAllHostAddr (Native method) at JAVA.NET.INETADDRESS$1.LOOKUPALLHOSTADDR (Unknown Source) at Java.net.InetAddress.getAddressesFromNAmeservice (Unknown Source) ... More

At first glance feel inexplicable, never encountered such an anomaly, and finally found a solution on Google, first explain the cause of this anomaly, and then give a solution.

problem Reason

First look at the Unknownhostexception:w W is how to get it, cat/etc/sysconfig/network file, the contents are as follows:

[Root@w picture]# cat/etc/sysconfig/network
networking=yes
hostname=w

Hostname=w, oh oh, see here immediately feel the way out, the original is because the system did not find the host name of the corresponding IP, just modify the Linux hosts file.


Solutions
The above has analyzed the cause of the error, mainly because the system did not find the host name of the corresponding IP, modify the Linux Hosts file can be. The specific steps are as follows:
First, execute the cat/etc/hosts command, as follows:

[Root@w picture]# cat/etc/hosts
127.0.0.1   localhost localhost.localdomain Localhost4.localdomain4
:: 1         localhost localhost.localdomain localhost6 localhost6.localdomain6

And then execute the vi/etc/hosts command.

After the first line 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4, add W to save it.

The Hosts file after the modification is as follows:

[Root@w picture]# cat/etc/hosts
127.0.0.1   localhost localhost.localdomain Localhost4.localdomain4 W
:: 1         localhost localhost.localdomain localhost6 localhost6.localdomain6

When Linux looks up a domain name, it usually refers to locating the file/etc/hosts and then requesting the DNS server when it is not found.



OK, the problem has been settled here.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.