Tomcat启动异常:
JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available.
2017-05-18 18:44:38,122 ERROR - com.jd.common.network.LocalHost[44] - init hostname error!
java.net.UnknownHostException: localhost.localdomain: localhost.localdomain
at java.net.InetAddress.getLocalHost(InetAddress.java:1402)
at com.jd.common.network.LocalHost.<clinit>(LocalHost.java:42)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
参考http://stackoverflow.com/questions/1881546/inetaddress-getlocalhost-throws-unknownhostexception解决方案
1 查看host
命令 getent hosts 或 cat /etc/hosts
2 查看 localhost.localdomain 的地址
getent hosts localhost.localdomain
3 在/etc/hosts添加localhost.localdomain
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 localhost localhost.localdomain localhost6 localhost6.localdomain6
运行Test.java代码,正常了
import java.net.InetAddress;
import java.net.UnknownHostException;
public class Test{
public static void main(String[] args) {
try {
String hostName = InetAddress.getLocalHost().getHostName();
System.out.println(hostName);
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
分享到:
相关推荐
Caused by: java.net.UnknownHostException: openapi.alipay.com
linux系统下部署TOMCAT异常错误java.net.UnknownHostException :bogon: bogon 主要原因是主机映射原因 修改hosts文件即可
项目中碰到的,记录一下解决方案
【项目源码】-java网络...import java.net.UnknownHostException; import java.sql.Time; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; /** * 登录面板 *
import java.net.UnknownHostException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java...
参考百度Java文档Android Studio模拟定位服务 (安装插件)无法从百度获取地图数据错误显示如下: java.net.UnknownHostException: Unable to resolve host "loc.map.baidu.com": No address associated with ...
例如,在Java应用中,可以使用官方提供的`consul-client`库,通过`Registration`对象设置服务信息并调用`AgentService.register()`方法。对于其他语言,也有相应的SDK或HTTP请求实现。 5. **健康检查** Consul支持...
支持JMS(Java消息服务)协议,使得JMeter可以用于测试消息中间件的性能。 5. **Graph Results** 提供了丰富的图表组件,如响应时间和吞吐量图,帮助用户直观地理解测试结果。 四、注意事项 在使用Plugins ...
java HashMapDemo.java
**DBeaver 连接 MySQL 数据库的详细步骤** DBeaver 是一款强大的数据库管理工具,因其免费、开源且支持多种数据库的特点,深受开发者和DBA的青睐。它提供了直观的用户界面,使得数据库的管理和操作变得更加简单。...
java.net.UnknownHostException: java: java: No address associated with hostname at java.net.InetAddress.getLocalHost(InetAddress.java:1475) at net.sf.ehcache.Cache.<clinit>(Cache.java:222) ``` 此...
java.net.UnknownHostException: localhost.localdomain: localhost.localdomain: 未知的名称或服务 ``` 问题通常是由于主机名解析不正确导致的。以下步骤可帮助解决此类问题: 1. **编辑`/etc/hosts`文件**:添加...
一、 android java.net.UnknownHostException: Unable to resolve host"...": No address associated 错误 该错误是 Android 开发中常见的错误,主要是由于网络连接未开启或 Manifest 文件未标明网络访问权限所致。...
Java 和 .NET 是两个主要的软件开发平台,它们各自提供了丰富的工具和技术来构建各种类型的应用程序。这两个平台在很多方面都有交集,但也各有特点。 Java 是一种面向对象的编程语言,由Sun Microsystems(现在是...
import java.net.UnknownHostException; public class TCPClient { public static void main(String[] args) { try { Socket socket = new Socket("127.0.0.1",4444); OutputStream oStream = socket....
7. **配置和属性**:Java系统属性如`java.net.preferIPv6Addresses`和`java.net.preferIPv4Stack`可以用来配置系统首选的IP版本。 8. **异常处理**:处理网络编程中常见的异常,如`UnknownHostException`, `...
import java.net.UnknownHostException; public class NsLookup { public static void main(String[] args) { try { InetAddress address = InetAddress.getByName(args[0]); // 获取指定域名的InetAddress对象 ...
import java.net.UnknownHostException; public class ClientDemo { public static void main(String[] args) { try { InputStream in = new FileInputStream("D:\\Client"); byte[] buf = new byte[1024*1024...