今天部署应用到Tomcat,发现启动过程中有异常,验证码前台出不来,以为是此异常导致的,后来解决了java.net.UnknownHostException,登录页面的验证码还是出不来不知是何问题。

详细异常输出

报错方式:java.net.UnknownHostException: 主机名: 主机名

[plain]  view plain  copy
  1. java.net.UnknownHostException: RD-CD-APP122.wlyd.local: RD-CD-APP122.wlyd.local: ?..?..绉版.?..  
  2.     at java.net.InetAddress.getLocalHost(InetAddress.java:1473)  
  3.     at net.sf.ehcache.Cache.<clinit>(Cache.java:214)  
  4.     at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:296)  
  5.     at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:219)  
  6.     at net.sf.ehcache.CacheManager.configure(CacheManager.java:722)  
  7.     at net.sf.ehcache.CacheManager.doInit(CacheManager.java:439)  
  8.     at net.sf.ehcache.CacheManager.init(CacheManager.java:377)  
  9.     at net.sf.ehcache.CacheManager.<init>(CacheManager.java:259)  
  10.     at net.sf.ehcache.CacheManager.newInstance(CacheManager.java:1037)  
  11.     at net.sf.ehcache.CacheManager.newInstance(CacheManager.java:818)  
  12.     at net.sf.ehcache.CacheManager.create(CacheManager.java:799)  
  13.     at com.wlyd.fmcgwms.util.ehcache.EhcacheUtil.<clinit>(EhcacheUtil.java:18)  
  14.     at com.wlyd.fmcgwms.util.sysinit.InitSysProperties.setApplicationContext(InitSysProperties.java:55)  
  15.     at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:117)  
  16.     at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:92)  
  17.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:396)  
  18.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1505)  
  19.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)  
  20.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)  
  21.     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)  
  22.     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)  
  23.     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)  
  24.     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)  
  25.     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)  
  26.     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)  
  27.     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)  
  28.     at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)  
  29.     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)  
  30.     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)  
  31.     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)  
  32.     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)  
  33.     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)  
  34.     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)  
  35.     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)  
  36.     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)  
  37.     at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)  
  38.     at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)  
  39.     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)  
  40.     at java.util.concurrent.FutureTask.run(FutureTask.java:262)  
  41.     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
  42.     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
  43.     at java.lang.Thread.run(Thread.java:745)  
  44. Caused by: java.net.UnknownHostException: RD-CD-APP122.wlyd.local: ?..?..绉版.?..  
  45.     at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)  
  46.     at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)  
  47.     at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)  
  48.     at java.net.InetAddress.getLocalHost(InetAddress.java:1469)  
  49.     ... 41 more  
  50. 2016-12-29 17:11:38,875 [localhost-startStop-1] INFO  [org.quartz.core.SchedulerSignalerImpl] - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl  
  51. 2016-12-29 17:11:38,885 [localhost-startStop-1] INFO  [org.quartz.core.QuartzScheduler] - Quartz Scheduler v.1.8.5 created.  
  52. 2016-12-29 17:11:38,886 [localhost-startStop-1] INFO  [org.quartz.simpl.RAMJobStore] - RAMJobStore initialized.  
  53. 2016-12-29 17:11:38,888 [localhost-startStop-1] INFO  [org.quartz.core.QuartzScheduler] - Scheduler meta-data: Quartz Scheduler (v1.8.5) 'SpringJobSchedulerFactoryBean' with instanceId 'NON_CLUSTERED'  
  54.   Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.  
  55.   NOT STARTED.  
  56.   Currently in standby mode.  
  57.   Number of jobs executed: 0  
  58.   Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.  
  59.   Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.  

解决方法

命令:vi /etc/hosts

在最后一行添加:127.0.0.1 主机名。我的系统改成了如下图所示:

修改完成,保存文件,之后就不会有此异常发生了。


Logo

更多推荐