1

my server.xml has

< applicationManager autoExpand="true" / >
...
< application context-root="BaseX" id="BaseX" name="BaseX" type="war" location="C:\Program Files\BaseX.war" / >

when I start the application

server start myapp

the whole expanded folder is deleted and recreated. WebSphere\Liberty\usr\servers\myapp\apps\expanded\BaseX.war

since BaseX.war is my database i loose all the data with it after a simple re-start (stop and start)

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
Stefania Axo
  • 127
  • 13

1 Answers1

1

The best way to achieve this right now is to deploy your application as an expanded WAR rather than as an archive. Instead of the WAR archive c:\Program Files\BaseX.war, you would have a directory c:\Program Files\BaseX.war that contains the expanded BaseX.war file. In this case, the application would run directly from that directory and would not be expanded into apps/expanded.

You could also turn off expansion of applications by setting autoExpand to false on the applicationManager element, but that's likely not a good solution for you because you're writing directly to the application. If you followed this path, you would probably need to change the application to write data to a different location.

Brent Daniel
  • 355
  • 1
  • 4
  • are you saying to expand BaseX.war into another directory/folder? is there something to do on server.xml for this? – Stefania Axo Sep 13 '17 at 23:28
  • Nothing has to change in server.xml -- the application location can be either an archive file or an expanded directory. You wouldn't expand BaseX.war into another directory, but rather into a directory named BaseX.war (so you would have c:\program files\BaseX.war\WEB-INF\web.xml , etc, not c:\program files\BaseX.war\BaseX.war\WEB-INF\web.xml ) – Brent Daniel Sep 14 '17 at 14:30
  • I tried the following and it worked
    1. unzip BaseX.war into a folder C:\Program Files\BaseX 2. set server.xml not to expand and point to this new folder start and stop of the server do not delete the whole data
    – Stefania Axo Sep 14 '17 at 15:29
  • do i need to call it BaseX.war? this deleting of the expanded folder seems like a bug to me...is there a way to stop it? why is it happening with a simple restart? – Stefania Axo Sep 14 '17 at 15:32
  • The directory can be anything as long as you have 'type="war"' -- otherwise it would need the '.war' extension on the directory to figure out that it's a web application. – Brent Daniel Sep 15 '17 at 15:17
  • There isn't currently a way to prevent the refresh of the expanded directory on server start. It's possible this may change in the future, but best practice would still be to avoid writing data directly to application binaries (otherwise, any update to the binaries would result in deleting the existing data.) – Brent Daniel Sep 15 '17 at 15:26