TomDK
TomDK

Reputation: 1411

Keep files when deploying .war in Glassfish 3.12

I've got a bit of a problem with deployments on my project and after hours of searching the web I can't find an answer to this.

Situation: I am working on a Web application that lives of uploads and other files that get generated during use. To keep things simple I store these into: .../mywebapp/web/some subfolders/*

So far, so good.

My Problem: Every time I redeploy my project on the actual server (after updating classes/jsp's) Glassfish deletes the entire content of .../mywebapp/ during redeployment.

My Procedure so far:

  1. Export the latest version of my webapp as .war.
  2. Add the changed files into the .war file on the server (rename to .zip, then back to .war)
  3. Redeploy the .war on my server using the admin console (locahost:4848)

My question is This current procedure is very prone to dataloss (I could lose the files!) Is there a straight forward way where I can upload changes to my server without the risk of losing all the files that have been added during runtime?

Upvotes: 1

Views: 1170

Answers (2)

Chris Fremgen
Chris Fremgen

Reputation: 5358

I had this same issue, solved using XCOPY and Event Scheduler.

Effectively, you are continuously sync two folders

Run a scheduled task for the following batch file every X minutes

sync.bat:

xcopy "domain1\applications\%YOUR_APP_NAME%l\path\to\folder" "D:\folder\to\sync" /D /I /Y

xcopy "D:\folder\to\sync" "domain1\applications\%YOUR_APP_NAME%l\path\to\folder" /D /I /Y

Switches:

/D - Only copy newer files if the destination file exists

/I - If the destination does not exist, and you are copying more than one file, this switch assumes that the destination is a folder.

/Y - Overwrite without prompting

Upvotes: 0

vkraemer
vkraemer

Reputation: 9892

I see two choices:

  1. move the data 'out of harm's way' (find some place for it that isn't in the deployment directory; like a database)

  2. Switch to directory deployment instead of archive deployment.

The better of these two choices is the first one... It is more portable than the other; every server out there supports deploying archives. A lot of servers support directory based deployment... but they all do it a bit differently... so a directory structure that deploys on A may not deploy on B.

Upvotes: 1

Related Questions