| Author |
Tomcat in Eclipse File Write Permissions
|
Joshua Elkino
Ranch Hand
Joined: Jul 24, 2007
Posts: 91
|
|
In my servlet I have an image upload using FormFile. When writing to the directory in the tomcat\webapps\project\images .... i am getting an access denied error. it is erroring at f.mkdirs.. and if i comment that out i get the same error at the f.createNewFile. How can i grant tomcat to write to its own directory? Thanks! [ August 14, 2008: Message edited by: Bear Bibeault ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
You want to write the files into the web app? What happens if you need to redeploy?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Joshua Elkino
Ranch Hand
Joined: Jul 24, 2007
Posts: 91
|
|
Since i'm in development, i this is sufficient. I haven't tried it but i assume this will give me issues writing to another location. Am i correct to assume this?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
Originally posted by Ilya Elkind: Since i'm in development, i this is sufficient.
I have no idea what you mean by this. It doesn't really have much to do with your code, but with file permissions and users on your server. (Which is why I moved it here from Servlets.)
|
 |
Joshua Elkino
Ranch Hand
Joined: Jul 24, 2007
Posts: 91
|
|
first off thanks for your prompt responces. What i wrote had typos (sorry i should proof-read b4 posting). I was mentioning that i know if i redeploy i will loose everything but it isn't important right now since i'm in development rather than production. I will start clean anyway so anything i'm uploading is garbage. Currently i'm logged in as local admin and running tomcat through an eclipse plugin. I would assume that tomcat would take on the permissions as the user running it.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
I have no idea how Eclipse manages permissions. Hang onto your hat... I'll move this again to the IDEs forum where the Eclipse-savvy can comment.
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8142
|
|
|
Post the entire exception stacktrace. And what happens when you start tomcat outside Eclipse and run your program? Does it work?
|
[My Blog] [JavaRanch Journal]
|
 |
Joshua Elkino
Ranch Hand
Joined: Jul 24, 2007
Posts: 91
|
|
java.io.IOException: Access is denied at java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(Unknown Source) at com.m2m.actions.AddUserPicturesAction.execute(AddUserPicturesAction.java:95) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.m2m.filters.HibernateSessionReqFilter.doFilter(HibernateSessionReqFilter.java:41) 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:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) This is at f.createNewFile(); I haven't tried to deploy it on an external tomcat.
|
 |
Joshua Elkino
Ranch Hand
Joined: Jul 24, 2007
Posts: 91
|
|
when running it on an external tomcat5 (eclipse plugin is v6).. the same error occurs. I wasn't running this as a service or anything..just a standard launch.
|
 |
Joshua Elkino
Ranch Hand
Joined: Jul 24, 2007
Posts: 91
|
|
well i just uncommented out the f.mkdirs() and it seemed to work.. odd. Thanks everyone..
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
If you want the long explanation, I think you can search this forum and find one. Ever so often I go on a long-winded rant about why you should never try and write into any part of a web application. Short answer: because it doesn't always work. Treat the app as something read-only that isn't necessarily a real directory with real files in it. Eclipse isn't a web server, so if your webapp is attempting to write to itself, Eclipse doesn't get involved - all it's doing is running a copy of Tomcat in embedded mode. Technically, Tomcat's not doing it either. You're doing it to yourself in your webapp code. But as I said, you'll have a happier life if you don't do it at all.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: Tomcat in Eclipse File Write Permissions
|
|
|