http://ibatis.apache.org/dtd/ibatis-3-config.dtd Cause: java.net.ConnectException: Connection timed out: connect

最近发现我的一个web项目只要在家启动时候就出现一个连接错误的问题,大概如下:

Context initialization failed 
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [C:\Users\popc\IdeaProjects\aaaa2015\target\aaaa2015-0.0.1-SNAPSHOT\WEB-INF\classes\spring\configurations.xml]; nested exception is java.net.ConnectException: Connection timed out: connect 
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:408)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4544) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5016) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140) 
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812) 
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787) 
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:570) 
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1352) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:601) 
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297) 
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791) 
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:598) 
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:547) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:601) 
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297) 
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791) 
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1486)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:96) 
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1327)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1419)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:847) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:601) 
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) 
at sun.rmi.transport.Transport$1.run(Transport.java:177) 
at sun.rmi.transport.Transport$1.run(Transport.java:174) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.rmi.transport.Transport.serviceCall(Transport.java:173) 
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553) 
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808) 
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
at java.lang.Thread.run(Thread.java:722) 
Caused by: java.net.ConnectException: Connection timed out: connect 
at java.net.DualStackPlainSocketImpl.connect0(Native Method) 
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69) 
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) 
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) 
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) 
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) 
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) 
at java.net.Socket.connect(Socket.java:579) 
at java.net.Socket.connect(Socket.java:528) 
at sun.net.NetworkClient.doConnect(NetworkClient.java:180) 
at sun.net.www.http.HttpClient.openServer(HttpClient.java:378) 
at sun.net.www.http.HttpClient.openServer(HttpClient.java:473) 
at sun.net.www.http.HttpClient.<init>(HttpClient.java:203) 
at sun.net.www.http.HttpClient.New(HttpClient.java:290) 
at sun.net.www.http.HttpClient.New(HttpClient.java:306) 
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:995)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931) 
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849) 
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1299)
at java.net.URL.openStream(URL.java:1037) 
at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:796) 
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:756) 
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:267) 
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:826)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:524) 
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:580) 
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152) 
at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:253) 
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:201) 
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 56 more 
十一月 07, 2014 5:56:59 下午 org.apache.catalina.core.StandardContext startInternal 
SEVERE: Error listenerStart 
十一月 07, 2014 5:56:59 下午 org.apache.catalina.core.StandardContext startInternal 
SEVERE: Context [/aaaa2015] startup failed due to previous errors

配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE configuration

PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"

"http://ibatis.apache.org/dtd/ibatis-3-config.dtd">

<configuration>

    <plugins>

        <!-- 指定数据库分页方言Dialect, 其它方言:OracleDialect,SQLServerDialect,SybaseDialect,DB2Dialect,PostgreSQLDialect,MySQLDialect,DerbyDialect,HSQLDialect-->

        <plugin interceptor="cn.org.rapid_framework.ibatis3.plugin.OffsetLimitInterceptor">

            <property name="dialectClass" value="cn.org.rapid_framework.jdbc.dialect.MySQLDialect"/>

        </plugin>

    </plugins>



    <!-- 数据源通过spring注入 -->

    <!-- 

    <environments default="development">

        <environment id="development">

            <transactionManager type="JDBC" />

            <dataSource type="POOLED">

                <property name="driver" value="com.mysql.jdbc.Driver" />

                <property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8" />

                <property name="username" value="root" />

                <property name="password" value="123456" />

            </dataSource>

        </environment>

    </environments>

     -->    

</configuration>

 

经过IDE的代码异常提示,在配置文件applicationContext.xml的头文件中有一个头提示无法访问,于是copy 地址http://ibatis.apache.org/dtd/ibatis-3-config.dtd再浏览器中访问,果然请求超时,通过google发现更改地址就行了,在此记录下:

在配置文件中,将http://ibatis.apache.org/dtd/ibatis-3-config.dtd更改为http://mybatis.org/dtd/mybatis-3-config.dtd

参考地址:http://mybatis-user.963551.n3.nabble.com/Connection-time-out-error-td4026924.html

你可能感兴趣的:(Connection)