java - Spring hangs when loading bean definitions -


i have following java code:

applicationcontext context = new classpathxmlapplicationcontext                 ("classpath:applicationcontext.xml"); 

and following application context:

<beans xmlns="http://www.springframework.org/schema/beans"        xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xmlns:context="http://www.springframework.org/schema/context"        xmlns:mvc="http://www.springframework.org/schema/mvc"        xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd                http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context-4.1.xsd         http://www.springframework.org/schema/mvc         http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">  <mvc:annotation-driven/>     <context:component-scan base-package="in.ksharma"/> </beans> 

spring hangs when loading file. application not respond.

to find out why took thread dump. seems hang inside tcp connect request:

connecttoaddress():213, plainsocketimpl {java.net} connect():200, plainsocketimpl {java.net} connect():366, sockssocketimpl {java.net} connect():529, socket {java.net} connect():478, socket {java.net} doconnect():163, networkclient {sun.net} openserver():411, httpclient {sun.net.www.http} openserver():525, httpclient {sun.net.www.http} <init>():208, httpclient {sun.net.www.http} new():291, httpclient {sun.net.www.http} new():310, httpclient {sun.net.www.http} getnewhttpclient():987, httpurlconnection {sun.net.www.protocol.http} plainconnect():923, httpurlconnection {sun.net.www.protocol.http} connect():841, httpurlconnection {sun.net.www.protocol.http} getinputstream():1195, httpurlconnection {sun.net.www.protocol.http} setupcurrententity():676, xmlentitymanager {com.sun.org.apache.xerces.internal.impl} startentity():1314, xmlentitymanager {com.sun.org.apache.xerces.internal.impl} startdocumententity():1266, xmlentitymanager {com.sun.org.apache.xerces.internal.impl} setinputsource():280, xmldocumentscannerimpl {com.sun.org.apache.xerces.internal.impl} parse():409, schemaparsingconfig {com.sun.org.apache.xerces.internal.impl.xs.opti} parse():491, schemaparsingconfig {com.sun.org.apache.xerces.internal.impl.xs.opti} parse():510, schemadomparser {com.sun.org.apache.xerces.internal.impl.xs.opti} 

the address trying connect is:

www.springframework.org/162.159.245.187

what problem here?

check pom file. schema namespace have specified in application context correspond correct version of spring dependencies used?

what seems happening here spring tries load xsd document spring jar file unable due version mismatch. tries connect spring website , load there.

changing schema namespace correct version resolved problem:

<beans xmlns="http://www.springframework.org/schema/beans"        xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xmlns:context="http://www.springframework.org/schema/context"        xmlns:mvc="http://www.springframework.org/schema/mvc"        xsi:schemalocation="http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd        http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context-4.0.xsd         http://www.springframework.org/schema/mvc         http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -