最近,使用tomcat做服务器,实现java web程序。当然,做程序嘛,难免有错误,但是出现了错误,最大的希望就是tomcat能够告诉我,错误到底是什么?
当然了,具体的错误种类太多,常见的有语法错误,这一点还好处理;上升到逻辑错误,就难了;再一个就是,对于tomcat加载application的过程不清楚的话,也会出现不符合约定的错误啦,这个就更加难了。
还在tomcat有日志功能,在很大程度上帮助我们分析错误,定位错误。
logs目录:
2013-7-11 8:54:23 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.6.0_10\bin;
C:\CTeX\LOCALT~1\ty\bin;C:\CTeX\LOCALT~1\cct\bin;C:\CTeX\texmf\miktex\bin;C:\CTeX\gs\gs8.51\bin;C:\CTeX\WinEdt;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs,;
d:\Program Files\Tencent\QQPCMgr\6.6.2159.401;C:\Program Files\EgisTec Port Locker\;d:\Program Files\MATLAB\R2011a\runtime\win32;
d:\Program Files\MATLAB\R2011a\bin;F:\apache-ant-1.9.1\bin;d:\apache-maven-3.0.5\bin;E:\vim\GVimPortable;;.
2013-7-11 8:54:24 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
这个时候,还没有任何一个servlet被加载。但是catalina这个servlet容器正在后台加载对应的servlets。2013-7-11 9:02:39 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
2013-7-11 9:02:39 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 9393 ms
2013-7-11 9:02:39 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
2013-7-11 9:02:39 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.27
2013-7-11 9:02:39 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\Catalina\localhost\DormManaSys.xml
2013-7-11 9:02:39 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(E:\MDormintorySystem\DormManaSystem\WebRoot\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2013-7-11 9:02:40 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\Catalina\localhost\ProjectOne.xml
2013-7-11 9:02:40 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\bank
2013-7-11 9:02:40 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\docs
2013-7-11 9:02:40 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\host-manager
2013-7-11 9:02:40 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\manager
2013-7-11 9:02:41 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\myapp
2013-7-11 9:02:41 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT
2013-7-11 9:02:41 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\WebRoot
2013-7-11 9:02:41 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
2013-7-11 9:02:41 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
2013-7-11 9:02:41 org.apache.catalina.startup.Catalina start
信息: Server startup in 2047 ms
这个时候,work目录下的catalina目录下,会对应产生相应的目录,但是目录下的内容是空的。我们知道Servlet的加载有两种情况,[2013-07-11 09:09:43] [info] Commons Daemon procrun (1.0.10.0 32-bit) started
[2013-07-11 09:09:43] [info] Running 'Tomcat7' Service...
[2013-07-11 09:09:43] [info] Starting service...
[2013-07-11 09:09:44] [info] Service started in 1109 ms.
2013-07-11 09:09:43 Commons Daemon procrun stdout initialized
LogDate.txtthe water MARK file is located in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\waterMark.jpg
2013-07-11 09:43:35 Commons Daemon procrun stdout initialized
LogDate.txtthe water MARK file is located in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\waterMark.jpg
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
the original file is located in /test.jpg
next will deal with image showed
all files can be read!!!bla bla bla
attribute ADDED(message , Cannot call sendError() after the response has been committed)
attribute ADDED(e , java.lang.IllegalStateException: Cannot call sendError() after the response has been committed)
attribute ADDED(javax.servlet.error.exception , java.lang.IllegalStateException: Cannot forward after response has been committed)
initialize the request from client
attribute REPLACED(org.apache.catalina.ASYNC_SUPPORTED , true)
127.0.0.1 - - [11/Jul/2013:09:44:24 +0800] "GET / HTTP/1.1" 200 415
127.0.0.1 - - [11/Jul/2013:09:44:24 +0800] "GET /favicon.ico HTTP/1.1" 404 988
127.0.0.1 - - [11/Jul/2013:09:49:55 +0800] "GET /choose.jsp HTTP/1.1" 200 646
127.0.0.1 - - [11/Jul/2013:09:49:55 +0800] "GET /favicon.ico HTTP/1.1" 404 988
127.0.0.1 - - [11/Jul/2013:09:49:56 +0800] "GET /favicon.ico HTTP/1.1" 404 988
127.0.0.1 - - [11/Jul/2013:09:50:05 +0800] "GET /filter_image.jsp HTTP/1.1" 200 117
127.0.0.1 - - [11/Jul/2013:09:50:05 +0800] "GET /favicon.ico HTTP/1.1" 404 988
2013-7-11 10:06:16 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [default] in context with path [] threw exception
java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:339)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at test.Filter_Exception.doFilter(Filter_Exception.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at test.Filter_Log.doFilter(Filter_Log.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)