*
The moose likes Ant, Maven and Other Build Tools and the fly likes Deploy overwrites folder. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Deploy overwrites folder." Watch "Deploy overwrites folder." New topic
Author

Deploy overwrites folder.

Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
I have a folder : Resources where all my images are, but also the images my Users added. Everytime I deploy a new .war file this gets overwritten, forcing my Users to upload their pictures again. Is there any way of solving this?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yes. Don't store those images inside the web application's context. Store them in some other directory.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
More specifically, don't store the images that are coming from your user in a directory that gets overwritten during a deployment. Why would you?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
But wherever i put the folder in my web folder, its being included in the build map. Wich tells me it will be overwritten on deploy.
And if I don't put it in my web folder I can't seem to reach the images from a page.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Tristan Van Poucke:
And if I don't put it in my web folder I can't seem to reach the images from a page.
That's the second part of the fix. You'll need to write a servlet which receives an image name as a parameter and returns the image which it gets from the external directory.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Or if your application server supports it, you can define an external directory where the images are located.


JBoss In Action
Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
So what i understand from this, is that all I have to do is:
- Create a folder on my server f.e. UserResources
- Get all the images added by users from there directly using the full URL
f.e. http://MyServer:8080/UserResources
- Do not add this map in my war file.
And this problem should be solved right?
[ October 01, 2008: Message edited by: Tristan Van Poucke ]
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Tristan, if you were responding to my suggestion, then the tasks would be:

1) Create a directory in the host, say /opt/image
2) Configure the app server such that the context /UserResources, accessible via the URL http://MyHost:8080/UserResources, maps to the directory /opt/image
3) Ignore the /opt/image directory when creating the WAR

I prefer the term 'host' because it implies the physical (or virtual) machine on which the application server is running. I have seen the term 'server' used to mean the host in some cases and the application server in others, so the term 'server' tends to be ambiguous, which is not good when discussion precise configuration.
 
jQuery in Action, 2nd edition
 
subject: Deploy overwrites folder.
 
Similar Threads
Images in downloaded files
JSP with CSS does not display the background image
Displaying image problem
Accessing images under WEB-INF
write jboss service to perform a task at startup.