java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\localhost_access_log.2012-07-12.txt (Access is denied)
only doing a real deployment when I have a stable version of my project by copying the appropriate java class files into Tomcat's /webapps/WEB-INF/classes folder and restarting Tomcat
Stop right there: you should never put any files into webapps/WEB-INF
and expect anything good to come of it. Deploy your webapp properly, using a well-accepted packaging such as a WAR file or an exploded-WAR structure into the webapps directory.
Second, the problem is obvious: java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\localhost_access_log.2012-07-12.txt (Access is denied)
. Your Tomcat can't write to that file. Just because you are an admin doesn't mean that Tomcat can write to that directory: Tomcat doesn't play well with UAC as far as I know and you are trying to write to Program Files
which generally requires some ugly UI credentials-entry hack.
So, check your file (and directory) permissions. Check the uid of the Tomcat process: make sure they are all good. Finally, consider using CATALINA_HOME
and CATALINA_BASE
(read the documentation for how to do that) to fix all of your permissions issues.
Comments
-
kip2 almost 2 years
I'm trying to test my servlet by running it on Tomcat. However, I get the above error (sometimes this error occurs, but earlier the servlet was running fine). A few facts:
I've looked thoroughly at the explanations given by this similar problem, as well as in here, and here
When I attempt to restart Tomcat (from within Eclipse's "Servers" tab), I get some error log from the console:
"SEVERE: Failed to open access log file [~\Tomcat 7.0\logs\localhost_access_log.2012-07-12.txt]" and at the very end of the log output, there's "INFO: SessionListener: sessionDestroyed('E9A6117FDF54752D80A1B9B72F2B83D3') -- see more info at the bottom of this text
I've looked at my log files at " C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs" and there is not file with contents similar to the ones in item (2) above
I 'deploy' my application through Eclipse (that is, during development, I depend on Eclipse to start Tomcat), only doing a real deployment when I have a stable version of my project by copying the appropriate java class files into Tomcat's /webapps/WEB-INF/classes folder and restarting Tomcat
and most importantly, 5. Typing in "http://localhost:8080" leads me to the Tomcat homepage (so I'm pretty sure the server is running), whereas "http://localhost:8080/MyProjectName/MyServlet" in the browser leads to the error shown this question's title.
Any ideas/help? Thank you very much!
See more of the error logs here
>!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')
-
kip2 almost 12 yearson deployment, I followed directions in tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html, which includes the option to modify /WEB-INF, see section titled "Standard Directory Layout" Permissions: I'm using Windows and I'm not sure where to check the uid of a process (Task manager shows that the Tomcat process is stopped, yet it is running since calling localhost:8080 from the browser works). I no longer see the FileNotFoundException, but the console log is the same as before. Also, what specific part of the documentation explains permissions issues permanently?
-
Christopher Schultz almost 12 yearsYou misunderstand my comment about
webapps/WEB-INF
: Tomcat'swebapps
directory is special because under a default configuration, every directory there is treated as an auto-deploy webapp. If your webapp is called "foo" and should be available on/foo
, then it should be inwebapps/foo
and you should havewebapps/foo/WEB-INF
, etc. If you want your webapp to be the "root" context, you need to name the directoryROOT
instead. All of this is similarly valid if you want to use WAR files instead of exploded-WAR directories (e.g.foo.war
orROOT.war
-- case-sensitive). -
Christopher Schultz almost 12 yearsYou'll have to check the documentation for your OS version to determine both how to identify process owners as well as set their access privileges. I am not a Microsoft Windows administrator, so I can't help you there.