一个使用log4j,在tomcat启动时候的问题~~
我是第一次使用log4j,没有添加log4j时项目没有问题,添加log4j后,在web-inf/classes下放置log4j.properties,然后启动tomcat的时候,会报如下错误:
但是,项目仍可以运行,日志记录也可以正常输出,哪位高手帮我看一下?
ERROR - Parsing error processing resource path /WEB-INF/struts-config.xml
java.io.FileNotFoundException at org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContextURLConnection.java:297)
at java.net.URL.openStream(URL.java:1009)
at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:736)
at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:687)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:333)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)
------解决方案--------------------是在解析struts-config.xml文件时出错了
------解决方案--------------------你有幾個工程啊,可能不是這個工程出錯吧,tomcat是根據工程名字來挨個啟動的
------解决方案-------------------- <servlet>
<servlet-name> action </servlet-name>
<servlet-class> aa.ActionServlet </servlet-class>
<init-param>
<param-name> config </param-name>
<param-value> /WEB-INF/struts-config.xml </param-value>
</init-param>
<init-param>
<param-name> log4j </param-name>
<param-value> /WEB-INF/classes/resource/Logger.properties </param-value>
</init-param>
<init-param>
<param-name> debug </param-name>
<param-value> 2 </param-value>
</init-param>
<load-on-startup> 2 </load-on-startup>
</servlet>
例子 web.xml,你注意下.
<init-param>
<param-name> log4j </param-name>
<param-value> /WEB-INF/classes/resource/Logger.properties </param-value>
</init-param>