At work I often build RPMs based on git references. That might by the HEAD of a branch in a Stash user repository that is the basis for a pull request or simply the HEAD of master. I recently ran into a problem deploying those RPMs to a test environment. Changes made to the service did not take effect.

Our Java API webapp runs using Tomcat. The entire application and it’s dependencies are packaged within a WAR, which is then archived into an RPM. The SPEC file that defines how to build the RPM directs the installer (i.e. yum) to copy the new WAR into /var/lib/tomcat/webapps/. Tomcat is then responsible for extracting the WAR file into the same directory before the changes can take effect. Unfortunately, that doesn’t always happen. In addition to restarting Tomcat, I had to manually delete the previously extracted directories.

It wasn’t initially clear what was causing the problem. I had assumed there was an issue with the system I maintained for building the RPMs. I was finally able to understand where the problem existed by disassembling the Java binary files (i.e. .class files).

rpm2cpio webapp-1.0-0.noarch.rpm | cpio -idmv   # Extract the RPM archive
cd var/lib/tomcat/webapps               # Navigate to where the WAR is stored
jar -xvf api#config.war                 # Extract the WAR archive
jar -xvf WEB-INF/lib/api-service.jar    # Extract the applicable JAR archive
javap -c long/path/to/some.class        # Disassemble the binary into Java bytecode