cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hkvalheim
Level 3

Property file in WAR

I want to deploy a WAR file to a Apache Tomcat host.

Inside this WAR file there is a property file under /WEB-INF/classes/server.properties

Is it possible to edit values in this server.properties inside the WAR archive before deploy to the Apache Tomcat host?

Or is there another approach to this common task?
Labels (1)
0 Kudos
(5) Replies
ramalaks
Level 6

you can use modify text file action to do any search/replace etc..
0 Kudos
RobertDickau
Flexera Alumni

Perhaps see if the Modify Text File - In Archive action will work for you?
0 Kudos
hkvalheim
Level 3

I have tried to use the Action "Modify Text File - In Archive" under Install


Installed Archive: $USER_INSTALL_DIR$$/$Server.war
Archive Path: /WEB-INF/classes/server.properties


From the InstallLog.log

Modify Text File - In Archive: Server.war
Status: ERROR
Additional Notes: ERROR - There was a problem editing C:\Program Files\Server\Server.war: java.util.zip.ZipException: Entry: /WEB-INF/classes/server.properties not found in zip


Am I using the correct Action here? When I look at the help text I can read that this Action applies to ZIP or JAR. Is WAR type supported?

Any suggestions? :confused:
0 Kudos
RobertDickau
Flexera Alumni

I haven't tried it, but the action seems to identify a .war file as a possible target archive; as a test, does it work if you rename the file to be a .jar or .zip file?
0 Kudos
hkvalheim
Level 3

I get the same result when renaming the file from war to jar
Modify Text File - In Archive: Server.jar
Status: ERROR
Additional Notes: ERROR - There was a problem editing C:\Program Files\Server\Server.jar: java.util.zip.ZipException: Entry: /WEB-INF/classes/server.properties not found in zip


I also tried to create a plain new zip file and having the server.properties file at the root level. The result

Modify Text File - In Archive: Server.zip
Status: SUCCESSFUL


Then I tried to move server.properties to /WEB-INF/classes/ path in the same zip

Modify Text File - In Archive: Server.zip
Status: ERROR
Additional Notes: ERROR - There was a problem editing C:\Program Files\Server\Server.zip: java.util.zip.ZipException: Entry: /WEB-INF/classes/server.properties not found in zip


Finally I changed /WEB-INF to WEB-INF (dropping the very first slash / )

SUCCESSFUL!!

This also worked on the .war file.



🙂
0 Kudos