jodis遇到的问题
1. Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
java找jar包的网址 http://search.maven.org/
按照ArtifactId查询
2. SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
网上搜了一下下面是官方的解答http://www.slf4j.org/codes.html#StaticLoggerBinder:
This error is reported when the org.slf4j.impl.StaticLoggerBinder
class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar,slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.
You can download SLF4J bindings from the project download page.
大意是org.slf4j.impl.StaticLoggerBinder
无法载入到内存,原因是没有找到合适的绑定SLF4J,需要添加所列举的包中的某一个。
解决方法如下:
下载slf4j-nop.jar,添加到路径中,就解决问题了
3. Caused by: java.net.UnknownHostException: bogon
连接虚拟机连接不上,试了下主机和虚拟机之间能ping通,而且CentOs防火墙关闭了 还是提示该错误,在虚拟机里启动tomcat主机也访问不了,修改/etc/下 hosts文件,
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 bogon.localdomain bogon
加上了最后一行,感觉bogon是java的应用的主机名,加上后重启主机可以访问tomcat了,但是报了
Caused by: java.net.UnknownHostException: localhost.localdomain 错误
从新看了下 执行hostname 命令得到的主机名是localhost.localdomain 在网上找了修改主机名的命令
hostnamectl set-hostname localhost #修改成了localhost主机名
网上有修改/etc/hosts文件和修改/etc/sysconfig/network文件的貌似都不好使
4. Caused by: java.net.ConnectException: Connection refused: connect
java报错最上面是异常 下面有Caused by 看到异常先猜下啥问题,看第一个Caused by 有个报错 Connection.java:148 下面那个Caused by 最后 是 Connection.java:142 下面的是引起错误的原因 其实找错误特别是导入的jar包里的错误 应该先把你导的jar包的源文件的jar也下载下来,然后用eclipse载入进来,这 样,查错更方便,不要瞎猜。
然后找到出错的这段代码
public InetSocketAddress(String hostname, int port) { checkHost(hostname); InetAddress addr = null; String host = null; try { addr = InetAddress.getByName(hostname); } catch(UnknownHostException e) { host = hostname; } holder = new InetSocketAddressHolder(host, addr, checkPort(port)); }
可以看到 UnknownHostException 这是之前报的错误 这回报错的是 InetAddress.getByName(hostname),所以还是和hostname有关系 看了下自己的host文件
咨询了下@韦爵爷
![](http://images0.cnblogs.com/blog2015/549059/201505/081717385484612.png)
![](http://images0.cnblogs.com/blog2015/549059/201505/081716596424596.png)
还有你自己Windows本地hosts也得加上这一行
韦爵 2015/5/8 16:21:43
要不他那知道weiguoyuan是什么
![](http://images0.cnblogs.com/blog2015/549059/201505/081719272353173.png)
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 192.168.253.128 weiguoyuan
运行程序 终于搞定了
posted on 2015-05-05 16:08 weiguoyuan 阅读(846) 评论(0) 编辑 收藏 举报