• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

writing files during deployment

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I created a web application deployed in tomcat that basically writes a file under one of its folders (say, C:/tomcat5.5/webapps/mywebapp/temp) the first time it is used by a client and reads it to retrieve dynamic content (texts). I successfully ran and tested the app on my computer and two other computers (each one having its own fresh installation of tomcat where I deployed the application for testing). Now the odd thing is that when I sent the war file to my colleagues, two of them told me that the file cannot be written. We have the same version of tomcat. Could this be an issue with tomcat? Is there an option that I have to set so that files are allowed to be written during deployment?

Michael
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Webapps can be deployed several ways with Tomcat.
When you were developing it, you probably ran it as a directory structure on the file system. When it's run like this, getRealPath works and you can write to the directory structure of the webapp.

If you deploy the app as a packed war archive, getRealPath will return null and there won't be a file structure for it to write to.

Ask your colleagues to deploy it by placing the war file under the tomcat/webapps directory. Tomcat, by default, will unpack the war file when you deploy it this way.

This also could be a case of file permissions or, depending on how you determined the path a simple case of trying to write to a directory that doesn't exist.
 
michael echavez
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Ben for replying! I just resorted to *not* writing the file at all and just store the content as a String and retrieve it on demand. This makes the code a lot shorter and simpler. Thanks again!
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic