SchedulerException UnknownHostException

问题描述

一台新的虚拟机准备重新部署一下系统,启动时报获取不到主机名称

23:11:30.484 [main] ERROR o.q.i.StdSchedulerFactory - [instantiate,1238] - Couldn't generate instance Id!
org.quartz.SchedulerException: Couldn't get host name!
        at org.quartz.simpl.SimpleInstanceIdGenerator.generateInstanceId(SimpleInstanceIdGenerator.java:36)
        at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1235)
        at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1559)
        at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler(SchedulerFactoryBean.java:676)
        at org.springframework.scheduling.quartz.SchedulerFactoryBean.prepareScheduler(SchedulerFactoryBean.java:613)
        at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:501)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804)

...
Caused by: java.net.UnknownHostException: vm10-0-0-3: vm10-0-0-3: Name or service not known
        at java.net.InetAddress.getLocalHost(InetAddress.java:1506)
        at org.quartz.simpl.SimpleInstanceIdGenerator.generateInstanceId(SimpleInstanceIdGenerator.java:34)
        ... 57 common frames omitted
Caused by: java.net.UnknownHostException: vm10-0-0-3: Name or service not known
        at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324)
        at java.net.InetAddress.getLocalHost(InetAddress.java:1501)
        ... 58 common frames omitted

解决方案

查看问题为主机名称未知,并且获取到了设置的名称vm10-0-0-3

查看hostname

[agree@vm10-0-0-3 log]$ hostname
vm10-0-0-3

修改hosts,新增127.0.0.1 vm10-0-0-3

[root@vm10-0-0-3 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
*********** vm10-0-0-3
127.0.0.1 vm10-0-0-3

在这里插入图片描述

你可能感兴趣的:(问题记录,quartz,java,SchedulerExcep)