상세 컨텐츠

본문 제목

[Spring] 인터넷 연결이 끊겨있을때 발생하는 Spring xsd 관련 에러

개발/Spring

by 대충고양이짤 2015. 11. 26. 10:37

본문

문제 상황

인터넷이 연결되어 있을때는 정상이지만 연결되어 있지 않으면 톰캣 실행시 아래와 같은 에러 발생.

참고로 웹소켓을 연동한 프로젝트였다.


org.xml.sax.SAXParseException; lineNumber: 95; columnNumber: 84; schema_reference.4: 스키마 문서 'http://www.springframework.org/schema/util/spring-util-3.2.xsd' 읽기를 실패했습니다. 원인: 1) 문서를 찾을 수 없습니다. 2) 문서를 읽을 수 없습니다. 3) 문서의 루트 요소가 <xsd:schema>가 아닙니다.


Caused by: java.net.UnknownHostException: www.springframework.org


2014-09-04 10:34:22,195 [localhost-startStop-1] ERROR [org.springframework.web.servlet.DispatcherServlet] Context initialization failed

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 95 in XML document from class path resource [spring/spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 95; columnNumber: 84; cvc-complex-type.2.4.c: 일치하는 와일드 카드 문자가 엄격하게 적용되지만 'util:properties' 요소에 대한 선언을 찾을 수 없습니다.



문제 원인

스프링 설정 파일에서 xsd 파일 버전이 맞지 않아 발생하는 문제였다.


<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xmlns:p="http://www.springframework.org/schema/p"

xmlns:websocket="http://www.springframework.org/schema/websocket"

xsi:schemaLocation="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

http://www.springframework.org/schema/websocket

http://www.springframework.org/schema/websocket/spring-websocket-4.2.xsd">


웹소켓을 연동하기 위해 spring 4.2.1 release jar를 프로젝트에 포함시킨 것은 제대로 했으나 spring 설정 파일에서 xsd를 읽어올 때는 4.2.xsd 파일을 참조하도록 하였다. 이 둘의 버전이 맞지 않기 때문에 서버 구동시 프로젝트에 포함된 jar 가지고는 xsd를 읽을 수 없어 자동으로 인터넷에서 4.2 버전의 xsd 파일을 찾는 것 같다. 


이를 해결하기 위해서는,

1.프로젝트에 포함된 jar와 spring 설정 파일의 xsd 버전을 똑같이 맞춰주든지

2.그냥 설정 파일의 버전을 없애고 빌드하면 된다



문제 해결

Spring 설정 파일의 xsd 버전을 삭제했다. 


<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xmlns:p="http://www.springframework.org/schema/p"

xmlns:websocket="http://www.springframework.org/schema/websocket"

xsi:schemaLocation="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/websocket

http://www.springframework.org/schema/websocket/spring-websocket.xsd">



참고 사이트

schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring- beans-4.1.5.xsd - stackoverflow

Spring schemaLocation fails when there is no internet connection - stackoverflow

인터넷에 연결 안되면 Spring Framework 에러 발생. - 민서네집 티스토리 블로그


'개발 > Spring' 카테고리의 다른 글

[Spring][Error] cvc-complex-type.2.3... 에러  (0) 2015.11.24

관련글 더보기

댓글 영역