springmvc +tiles 启动后会报一个空指针异常 但是页面一刷新又能正常显示 异常是这样的 严重: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058) at org.apache.commons.digester.Digester.parse(Digester.java:1887) at org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:329) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) ...........后面就不复制了。 at java.lang.Thread.run(Unknown Source)
我之前也是找了好久,单看异常信息很难发现建议使用log4j打印日志, log4j 内容如下: log4j.rootLogger=DEBUG,A1 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n 在web.xml配置如下: <context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<listener> <listener-class> org.springframework.web.util.Log4jConfigListener </listener-class> </listener> 注意 slf4j-log4j12-1.6.2.jar , slf4j-api-1.6.2.jar ,jcl-over-slf4j-1.6.2.jar这几个jar版本问题。 此时报的异常时:java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"。 经过查找发现 原来是xercesImpl.jar版本过低的原因。我升级为xercesImpl-2.9.1.jar就行了。