zoukankan      html  css  js  c++  java
  • Mac OS X中bogon的处理

    起因

    最近写一个项目,之前在eclipse里的tomcat启动是没问题的,最近不知怎么了,启动的时候ehcache会报一个错误,说java.net.UnknownHostException: bogon: bogon: nodename nor servname provided, or not known.下面是错误日志的全部内容:

    11:46:56,905 ERROR localhost-startStop-1 [net.sf.ehcache.Cache:202] - Unable to set localhost. This prevents creation of a GUID. Cause was: bogon: bogon: nodename nor servname provided, or not known
    java.net.UnknownHostException: bogon: bogon: nodename nor servname provided, or not known
    	at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
    	at net.sf.ehcache.Cache.<clinit>(Cache.java:200)
    	at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:302)
    	at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:218)
    	at net.sf.ehcache.CacheManager.configure(CacheManager.java:599)
    	at net.sf.ehcache.CacheManager.init(CacheManager.java:358)
    	at net.sf.ehcache.CacheManager.<init>(CacheManager.java:299)
    	at net.sf.ehcache.CacheManager.create(CacheManager.java:697)
    	at net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory.start(SingletonEhCacheRegionFactory.java:62)
    	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:238)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
    	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:863)
    	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:782)
    	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:610)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4961)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5455)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: java.net.UnknownHostException: bogon: nodename nor servname provided, or not known
    	at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    	at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
    	at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
    	at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
    	... 36 more
    

    虽然报错了,但是不影响程序正常使用.

    解决

    这个bogon怎么都没找到我的程序里哪里有这个东西.网上查了一下,好像和路由映射有关系.最后查一篇文章,说这个问题只有mac会遇到.处理方法就是对bogon做个DNS解析指向127.0.0.1.

    修改文件/etc/hosts,在里面增加对127.0.0.1的解析.

    127.0.0.1    bogon    localhost 
    

    保存生效后,再启动tomcat就没这个问题了.

    参考

    关于作者

  • 相关阅读:
    shell 自动登录 上传 下载
    用例设计----PICT&Allpairs
    已有实例 Oracle 下新增实例
    【原创】安卓兼容性测试
    【原创】某版本性能测试
    【原创】Jmeter正则表达式提取json中多个关联值
    【转】四种常见的 POST 提交数据方式
    rfw使用接口库测试--FAIL : UnicodeEncodeError: 'ascii' codec can't encode characters in position
    【原创】Robotframework 简介
    java学习笔记_内存分析
  • 原文地址:https://www.cnblogs.com/qyf404/p/5072609.html
Copyright © 2011-2022 走看看