这几天在开发过程中,启动项目会出现一个Timeout的异常
java.net.SocketTimeoutException: connect timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:525) at sun.net.NetworkClient.doConnect(NetworkClient.java:158) at sun.net.www.http.HttpClient.openServer(HttpClient.java:394) at sun.net.www.http.HttpClient.openServer(HttpClient.java:529) at sun.net.www.http.HttpClient.<init>(HttpClient.java:233) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.http.HttpClient.New(HttpClient.java:323) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049) at net.sf.ehcache.util.UpdateChecker.getUpdateProperties(UpdateChecker.java:108) at net.sf.ehcache.util.UpdateChecker.doCheck(UpdateChecker.java:72) at net.sf.ehcache.util.UpdateChecker.checkForUpdate(UpdateChecker.java:60) at net.sf.ehcache.util.UpdateChecker.run(UpdateChecker.java:51) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462)
从异常名称(SocketTimeoutException)来看是一个socket连接超时,应该是连接其他资源出现的异常。
接着看堆栈的信息,发现有sun.net.www.http.HttpClient,定位这是一个http请求。但是程序在启动的时候并没有去连接任何外部的http资源啊?奇怪了~继续向下看看会不会有新的发现吧。
果然有发现,ehcache,可爱的缓存怎么还会去请求http资源呢?程序使用RMI方式做ehcache集群配置,不应该会有http请求啊,先不想了,跟到源码里看一下吧。
run->checkForUpdate->doCheck都没什么内容,跟着逻辑就进到了net.sf.ehcache.util.UpdateChecker.getUpdateProperties(其实这个类名已经说明这是在做更新检查了,我竟然忽略的看类名)
private Properties getUpdateProperties(URL updateUrl) throws IOException { URLConnection connection = updateUrl.openConnection(); connection.setConnectTimeout(CONNECT_TIMEOUT); InputStream in = connection.getInputStream(); try { Properties props = new Properties(); props.load(connection.getInputStream()); return props; } finally { if (in != null) { in.close(); } } }
扔断点,启动调试观察updateUrl(我竟然还没意识到这是在检测更新)
http://www.terracotta.org/kit/reflector?pageID=update.properties&kitID=ehcache.default&id=-1062731420&os-name=Windows+7&jvm-name=Java+HotSpot%28TM%29+Client+VM&jvm-version=1.6.0_18&platform=x86&tc-version=2.6.3&tc-product=Ehcache+Core+2.6.3&source=Ehcache+Core&uptime-secs=1&patch=UNKNOWN
这么长的地址,但是看这个域名挺眼熟,好像是......没再想了,先把地方放到浏览器上看看是什么
## Top level keys # general.notice = This notice should rarely, if ever, be used as everyone running ehcache will see it ## 2.6.5 -- latest release 2.6.5.updates = 2.6.5.notices = This is the latest GA release. 2.6.5.release-notes = http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.6 ## 2.6.3 2.6.3.updates = 2.6.5 2.6.3.notices = This is the latest GA release. 2.6.3.release-notes = http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.6 ## 2.6.2 2.6.2.updates = 2.6.5 2.6.2.notices = We recommend upgrading to 2.6.5, our latest GA release 2.6.2.release-notes = http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.6 ## 2.6.0 2.6.0.updates = 2.6.5 2.6.0.notices = We recommend upgrading to 2.6.5, our latest GA release 2.6.0.release-notes = http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.5 ## 2.5.7 2.5.7.updates = 2.6.5 2.5.7.notices = We recommend upgrading to 2.6.5, our latest GA release 2.5.7.release-notes = http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.5 2.5.6-SNAPSHOT.updates = 2.6.5 ## 2.5.6 2.5.6.updates = 2.6.5 2.5.6.notices = We recommend upgrading to 2.6.5, our latest GA release 2.5.6.release-notes = http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.5
这是什么东西?好像是版本更新~版本更新?版本更新!竟然是版本更新!打开ehcache.xml检查一下
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true">
竟然真的启动了检查更新,折腾了一大圈,竟然是ehcache在检查版本更新,可能是我浏览器挂了goagent的原因,在浏览器里访问时正常的,但是在程序中确无法访问,所以就出现了Timeout的异常。
把updateCheck改成false就解决了。(写了这么一大堆就最后一句话有用。^_^)
相关推荐
NULL 博文链接:https://yongtree.iteye.com/blog/272293
1.解压缩到目录下,复制ehcache-monitor-kit-1.0.0\lib\ehcache-probe-1.0.0.jar包到application的web-inf/lib目录下 2.将以下配置copy的ehcache.xml文件的ehcache标签中,注:上述链接中说的配置少写了个probe包名...
EhCache
hibernate+ehcache hibernate+ehcache hibernate+ehcache hibernate+ehcache hibernate+ehcache
ehcache-3.8.1.jar
hibernate ehcache.xml 配置详解
EhCache 是一个纯Java的进程内缓存框架,具有快速、精干等特点,是Hibernate中默认的CacheProvider。 Ehcache是一种广泛使用的开源Java分布式缓存。主要面向通用缓存,Java EE和轻量级容器。它具有内存和磁盘存储,...
spring3整合EhCache注解实例
ehcache所需的ehcache-core-2.5.2.jar及其源码ehcache-core-2.5.2-sources.jar
ehcache资料(包含ehcache jar包)
赠送jar包:ehcache-3.9.9.jar; 赠送原API文档:ehcache-3.9.9-javadoc.jar; 赠送源代码:ehcache-3.9.9-sources.jar; 赠送Maven依赖信息文件:ehcache-3.9.9.pom; 包含翻译后的API文档:ehcache-3.9.9-javadoc-...
Ehcache 的一个简单demo案例 了解如何使用ehcache 以及掌握一些基本的api
EHCache_技术文档 EHCache缓存 spring缓存
包含EHCache.jar和EHCache 技术文档.pdf
ehcache所需jar包 cglib-nodep-2.2.jar ehcache-core-2.5.2.jar ehcache-spring-annotations-1.2.0.jar guava-13.0.1.jar ehcache-terracotta-2.5.2.jar slf4j-api-1.6.1.jar slf4j-log4j12-1.6.1.jar terracotta-...
EhCache 是一个纯 Java 的进程内缓存框架,具有快速、精干等特点,是 Hibernate 中默认的 CacheProvider。Ehcache 是一种广泛使用的开源 Java 分布式缓存。主要面向通用缓存,Java EE 和轻量级容器。它具有内存和...
Ehcache经典中文教程Ehcache内存框架介绍 —高成勇 安装 配置 编码接口介绍 api
ehcache学习文档 ehcache 缓存
ehcache jar包
ehcache-3.4.0.jar ehcache .jar ehcache-3.4.0.jar ehcache .jar