Changing values inside JAR files that are inside EAR/WAR files, at deployment time.

This section relates to the SearchReplaceTask

Please see the Full Tasks Documentation for details of how to call this task from your orchestration file.

What is this feature?

Often we see third party products that have some environment specific information such as database schema name hard coded in property files or xml config files within JAR files packaged within the EAR file.

So we need to change this value to be specific to our deployment environments for our application release automation to operate correctly. For example the default schema name in the product is FEEDSRV. We would like to create different schema for each environment say FEEDSRV_SCD_OWNER.

In this situation you can use this feature.

How do I enable it?

Search Replace inside a jar or war that is inside an ear

Edit your usual SearchReplaceTask as shown below.

  1. Add one PROPERTY line for each search string in the SearchReplaceTask entries section
  2. Make sure the Jar name is correct and has :: delimiter, E.g.: RD_R1_FeedService.jar::FEEDSRV FEEDSRV_SCD_OWNER

    A standard search/replace entry:

    Type            Key                                                                     Value
    
    PROPERTY        c:/websphere/PortalServer/log/          /usr/websphere/wascell01/AppServer/logs/WebSphere_Portal/

    A search replace inside a jar file found in the directoryToSearch entry. The example entry will search for the RD_R1_FeedService.jar and replace any occurrences of string "FEEDSRV" with "FEEDSRV_SCD_OWNER" inside this jar.

    Type            Key                                                                     Value
    
    PROPERTY        RD_R1_FeedService.jar::FEEDSRV          FEEDSRV_SCD_OWNER

How does it work?

The deployment framework extracts the EAR file as part of the normal deployment.

  • If there is a PROPERTY entry in the SearchReplaceTask for jar, first it searches for the jar file specified.
  • Next it extracts the jar file and looks for the search string in every text file (not binary files such as .class) and replaces with the string supplied.
  • Then it repackges the jar. If more than one jar of the same found in different directories it repeats this for each one of them.
  • This process is repeated for each definition provided in the props file.