본문 바로가기
Programming/DevOps, Tools

[TOMCAT] webAppRootkey 지정

by kghworks 2022. 2. 24.

목차

  • 에러 메시지
  • 원인
  • 해결책

 


에러 메시지

 

java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [.../tomcat/webapps/애플리케이션A/] instead of [../tomcat/webapps/애플리케이션B/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!

해석 : "webapp.root"라는 value가 이미 설정되어있으니 web.xml'webAppRootKey'  context-param에 유니크한 value를 지정하라!

 


원인

 web.xml의  context-param의 value는 system property의 key로 설정된다. 별도의 설정이 없다면 default 값은 "webapp.root"이다. 이 property는 아래와 같이 호출할 수 있을 것이다.

 

System.getProperty("webapp.root")

 

 이는 하나의 was에 2개 이상의 웹 app을 구동 중인 환경에서 문제가 된다. 예를 들어 애플리케이션 A, B를 구동 중일 때 각 애플리케이션에서 system property의 key값이 동일하게 "webapp.root"인 것이다. 서로 다른 webapp일지라도 system property에서 동일한 key값을 사용할 수없기 때문에 에러가 발생하는 것이다. 


해결책

 각 애플리케이션의 web.xml에 아래와 같이 서로 다른 value로 지정해주면 해결된다. (없으면 context-param태그를 추가해서 명시해준다.)

 

애플리케이션 A web.xml

	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>A.root</param-value>
	</context-param>

 

애플리케이션 B web.xml

	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>B.root</param-value>
	</context-param>

 

 각 param-value는 임의의 값이므로 각자 판단하여 지정해주면 된다.

 

댓글