我正在尝试通过在Tomcat上运行来测试我的servlet。但是,我得到上述错误(有时会发生此错误,但早期servlet运行正常)。一些事实:
我仔细研究了this similar problem以及here和here
当我尝试重启Tomcat时(从Eclipse的“Servers”选项卡中),我从控制台获得了一些错误日志:
“严重:无法打开访问日志文件[〜\ Tomcat 7.0 \ logs \ localhost_access_log.2012-07-12.txt]”并在日志输出的最后,有“INFO:SessionListener:sessionDestroyed(' E9A6117FDF54752D80A1B9B72F2B83D3') - 请参阅本文底部的更多信息
我在“C:\ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ logs”中查看了我的日志文件,并且没有文件内容与上面第(2)项中的内容类似
我通过Eclipse部署'我的应用程序(也就是说,在开发期间,我依靠Eclipse来启动Tomcat),只有在我拥有一个稳定版本的项目时通过复制相应的java类才进行真正的部署文件到Tomcat的/ webapps / WEB-INF / classes文件夹并重启Tomcat
最重要的是, 5.键入“http://localhost:8080”会将我引导至Tomcat主页(因此我非常确定服务器正在运行),而浏览器中的“http://localhost:8080/MyProjectName/MyServlet”会导致错误显示此问题的标题。
任何想法/帮助? 非常感谢你!
在此处查看更多错误日志
>!Jul 12, 2012 6:18:18 PM org.apache.catalina.core.AprLifecycleListener init
INFO: 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\Java\jdk1.7.0\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Users\Kiptoo\introcs\java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem;C:\Program Files\MiKTeX 2.8\miktex\bin;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Matlab\R2010a\runtime\win32;C:\Program Files\Matlab\R2010a\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\QuickTime\QTSystem;C:\Users\Kiptoo\introcs\bin;C:\Users\Kiptoo\introcs\java\bin;C:\Python27;C:\Program Files\Eclipse;;.
Jul 12, 2012 6:18:20 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jul 12, 2012 6:18:20 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 12, 2012 6:18:20 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2050 ms
Jul 12, 2012 6:18:20 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 12, 2012 6:18:20 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Jul 12, 2012 6:18:20 PM org.apache.catalina.valves.AccessLogValve open
SEVERE: Failed to open access log file [C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\localhost_access_log.2012-07-12.txt]
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\localhost_access_log.2012-07-12.txt (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at org.apache.catalina.valves.AccessLogValve.open(AccessLogValve.java:1115)
at org.apache.catalina.valves.AccessLogValve.startInternal(AccessLogValve.java:1222)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:185)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1144)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:782)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Jul 12, 2012 6:18:20 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\AndroidTest
Jul 12, 2012 6:18:20 PM org.apache.catalina.core.StandardContext postWorkDirectory
WARNING: Failed to create work directory [C:\Program Files\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\AndroidTest] for context [/AndroidTest]
Jul 12, 2012 6:18:21 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [175] milliseconds.
Jul 12, 2012 6:18:21 PM org.apache.jasper.EmbeddedServletOptions <init>
SEVERE: The scratchDir you specified: C:\Program Files\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\AndroidTest is unusable.
Jul 12, 2012 6:18:21 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\docs
Jul 12, 2012 6:18:21 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\examples
Jul 12, 2012 6:18:21 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 12, 2012 6:18:21 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 12, 2012 6:18:21 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@ff8399')
Jul 12, 2012 6:18:21 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\host-manager
Jul 12, 2012 6:18:22 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\manager
Jul 12, 2012 6:18:22 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT
Jul 12, 2012 6:18:22 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jul 12, 2012 6:18:22 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 12, 2012 6:18:22 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2225 ms
Jul 12, 2012 6:19:22 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: sessionDestroyed('E9A6117FDF54752D80A1B9B72F2B83D3')
答案 0 :(得分:3)
通过将适当的java类文件复制到Tomcat的/ webapps / WEB-INF / classes文件夹并重新启动Tomcat ,只有在我拥有稳定版本的项目时才进行实际部署
停在那里:你永远不应该把任何文件放到webapps/WEB-INF
中,并期待它有什么好处。使用广为接受的包装(如WAR文件或爆炸WAR结构)正确部署Web应用程序到webapps目录中。
其次,问题很明显:java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\localhost_access_log.2012-07-12.txt (Access is denied)
。您的Tomcat无法写入该文件。仅仅因为你是管理员并不意味着Tomcat可以写入该目录:据我所知,Tomcat与UAC不能很好地兼容,并且你试图写入Program Files
,这通常需要一些丑陋的UI凭据-entry hack。
因此,请检查您的文件(和目录)权限。检查Tomcat进程的uid:确保它们都很好。最后,请考虑使用CATALINA_HOME
和CATALINA_BASE
(阅读文档了解如何执行此操作)来修复所有权限问题。