`
it_star
  • 浏览: 7928 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

解决CP30下的Failed to get local InetAddress for VMID问题

阅读更多
报错如下:
INFO, generateVmId(C3P0ImplUtils.java 125), 2016-08-12_16:07:24, Failed to get local InetAddress for VMID. This is unlikely to matter. At all. We'll add some extra randomness
java.net.UnknownHostException: vzw86117.puppetclient: vzw86117.puppetclient: unknown error
        at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
        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)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1088)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1040)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:505)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1471)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1216)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1471)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1216)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1081)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1006)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:904)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:527)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.UnknownHostException: vzw86117.puppetclient.163.com: unknown error
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
        at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
        ... 72 more


报错原因是:

源码大概是这段:
public final class C3P0ImplUtils {
try{
      dos.write( InetAddress.getLocalHost().getAddress() );
    }catch (Exception  e)
      {
       if (logger.isLoggable(MLevel.INFO))
             logger.log(MLevel.INFO, "Failed to get local InetAddress for VMID. This is unlikely to matter. At all. We'll add some extra randomness", e);
           dos.write( srand.nextInt() );
}
 
}


由于linux优先加载/etc/hosts去寻找vzw86117.puppetclient对应的ip是多少,结果并未找到,所以cp30中会报错如上方,这个vzw86117.puppetclient其实对应的是主机名,debian系统中对应保存在/etc/hostname中。

解决办法:
修改/etc/hosts文件
vi /etc/hosts 在行127.0.0.1 localhost localhost.localdomain 后加上vzw86117.puppetclient保存即可。
分享到:
评论

相关推荐

    getlocalIp_获取本地IP工具java_服务器_

    由于`InetAddress.getLocalHost()`通常返回环回地址,所以在实际应用中,我们通常需要遍历所有网络接口,通过`NetworkInterface.getNetworkInterfaces()`获取,然后使用`NetworkInterface.getInetAddresses()`获取该...

    InetAddress和URL

    for (InetAddress addr : addresses) { System.out.println(addr.getHostAddress()); } ``` ##### 2. 操作与属性 - **比较两个`InetAddress`对象**:`equals(Object obj)` 方法可以用来判断两个`InetAddress`...

    InetAddress 类中dns解析后域名、ip清空

    解决这个问题的方法是,使用反射技术来清空InetAddress类中的私有成员变量map。在Android系统中,InetAddress类的私有成员变量map的存储位置在不同版本中有所不同。在Android 4.0以下的版本中,域名和IP键值对存放在...

    网络编程 InetAddress 的使用

    ### 知识点:网络编程中的InetAddress类使用方法 在网络编程中,`InetAddress` 类是Java标准库中用于处理互联网地址的核心类之一。它主要用于封装和操作IP地址,并提供了一系列方法来获取和处理IP地址相关的数据。...

    InetAddress源码

    在Java编程语言中,`InetAddress`类是网络程序设计中的核心组件,它主要用于表示互联网协议(IP)地址。这个类及其相关方法提供了获取和解析主机名与IP地址的能力,无论是本地主机还是远程主机。在分布式系统中,`...

    InetAddress域名解析

    InetAddress域名解析

    域名转IP(InetAddress)

    String hostname = inetAddress.getHostName(); Log.d("TAG", "Host Name: " + hostname); } catch (UnknownHostException e) { e.printStackTrace(); } ``` 3. **检查是否可达**: `InetAddress`还提供了`...

    Java网络编程基础-InetAddress类与URL类

    Java网络编程是开发分布式应用程序的关键部分,InetAddress和URL类在其中扮演...在学习和实践中,不仅要掌握基本的API使用,还要注意异常处理、安全性问题以及网络环境的差异,以便在各种场景下都能编写出健壮的代码。

    InetAddress测试代码

    InetAddress类的代码,用来获取主机名和IP地址

    iOS获取用户设备当前的IP地址

    在iOS开发中,获取用户...需要注意的是,获取IP地址时应考虑到用户的隐私问题,确保在必要且合法的情况下进行,并提供足够的透明度。同时,由于网络环境的动态变化,建议在需要时实时获取IP地址,而不是一次性存储。

    java 网络协议(一)InetAddress和Socket(含源码)

    总的来说,理解`InetAddress`和`Socket`的工作原理及其源码,能够帮助Java开发者更有效地处理网络通信问题,提高程序的稳定性和性能。通过阅读`ch02Internet`中的相关资料,可以进一步学习和实践这些概念。

    How to get all the IP available in LAN using java

    System.out.println("Host Name: " + inetAddress.getHostName()); } ``` `isReachable()`方法可以用来检查设备是否在线,但请注意,它可能需要管理员权限才能正确工作。 5. **注意网络安全和性能**: 在实际...

    示例3.1 使用InetAddress

    在Java编程语言中,`InetAddress`类是网络编程的核心组件之一,主要用于处理IP地址和主机名之间的转换。本示例3.1将深入探讨如何使用`InetAddress`...在处理网络编程问题时,理解并熟练使用`InetAddress`是非常重要的。

    解决linux找不到hostname的处理

    ### 解决Linux服务错误UnknownHostException的方法 在Linux环境中运行服务时,可能会遇到“UnknownHostException”的异常情况,这通常发生在尝试访问或设置主机名时出现问题。本文将详细介绍如何诊断并解决这一问题...

    InetAddress的用法2---马克-to-win Java视频

    InetAddress的用法2---马克-to-win Java视频 马克Java社区

    Java中的IP地址和InetAddress类使用详解

    2. `getHostName()`:返回InetAddress对象所包含的域名。 3. `getHostAddress()`:返回InetAddress对象所包含的IP地址。 4. `getLocalHost()`:返回本地主机的InetAddress对象,包含本地主机的域名和IP地址。 在...

    InetAddress的用法1---马克-to-win java视频

    InetAddress的用法1 java视频 马克java社区 马克towin

    Android开发之InetAddress基础入门简介与源码实例

    通过理解和掌握InetAddress的这些特性,开发者可以更有效地处理Android应用中的网络通信问题,例如检查网络连接、解析域名、建立网络连接等。在实际项目中,根据需求灵活运用这些方法,可以极大地提高网络功能的稳定...

    设置 dns (Domain Name System) 系统的编程,可扫描ip,

    在Java中,可以使用java.net.InetAddress类来获取IP地址;在C#中,System.Net.Dns类提供了类似的功能。 以下是使用编程设置DNS的一些关键步骤: 1. **DNS查询**:通过发送DNS查询请求(通常是类型A的查询,用于...

Global site tag (gtag.js) - Google Analytics