자바/Spring
톰캣에서 Spring & Log4j 리스너 사용 시 발생가능한 문제
finkle
2008. 5. 6. 13:05
톰캣에서 Spring & Log4j 리스너 사용 시 발생가능한 문제
예외 메시지 1 : Error reading tld listeners java.lang.NullPointerException
예외 메시지 2 : ApplicationContext.java:647 : Shutting down log4j
문제는 org.springframework.web.util.Log4jConfigListener가 org.springframework.web.context.ContextLoaderListener 전에 로드되어야 한다는 점이다.
샘플 web.xml
<!-- [Log4j configuration file path] =========================================== -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/conf/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- [PropertySet configuration file path] ===================================== -->
<context-param>
<param-name>propertyConfigLocation</param-name>
<param-value>/WEB-INF/conf/property-set.xml</param-value>
</context-param>
<listener>
<listener-class>com.srpost.salmon.spi.propertyset.PropertySetConfigListener</listener-class>
</listener>
<!-- [Spring configuration file path] ========================================== -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/application-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- [Jakarta common-upload temp file cleaner] ================================= -->
<listener>
<listener-class>org.apache.commons.fileupload.servlet.FileCleanerCleanup</listener-class>
</listener>