Skip to content

Enhancement: Support Executable WAR Files via BP_EXECUTABLE_JAR_LOCATION #311

@sabomichal

Description

@sabomichal

Enable support for executable WAR files in the executable-jar buildpack by allowing .war files specified via BP_EXECUTABLE_JAR_LOCATION to be treated as valid runnable JVM packages.

Describe the Enhancement

The executable-jar buildpack currently does not recognize a .war file specified via the BP_EXECUTABLE_JAR_LOCATION environment variable as a valid JVM application package, even when the WAR is fully executable (i.e., runnable via java -jar). This behavior unnecessarily limits support for Spring Boot WARs, which are explicitly designed to be executable and self-contained.

Executable WARs are a first-class citizen in the Spring Boot ecosystem, using a Main-Class such as org.springframework.boot.loader.WarLauncher. Users should be able to point to a .war file using BP_EXECUTABLE_JAR_LOCATION and have it work identically to .jar files.

Motivation

Spring Boot enables users to package applications as executable WARs, combining the benefits of WAR-based servlet configuration and modern containerization:

  • WARs maintain compatibility with traditional application servers and CI/CD pipelines.
  • Executable WARs support standalone execution (java -jar app.war), using embedded servlet containers (Tomcat, Jetty, Undertow).
  • This format is especially useful in migration scenarios from legacy WAR deployments to containerized Spring Boot apps.

According to Spring Boot documentation, executable WARs are explicitly supported:

A Spring Boot WAR can be executed using java -jar, and it will launch with an embedded servlet container.

Despite this, the executable-jar buildpack fails detection or execution if the file pointed to by BP_EXECUTABLE_JAR_LOCATION has a .war extension, even if it includes a valid Main-Class.

Expected Behavior

  • The buildpack should recognize .war files as valid targets if BP_EXECUTABLE_JAR_LOCATION is explicitly set.
  • Detection logic should validate the presence of Main-Class and treat .war files equivalently to .jar files if the file is executable.

Possible Solution

  1. Extend the executable-jar buildpack logic to allow .war files when:
    • BP_EXECUTABLE_JAR_LOCATION is set to a .war file
    • Main-Class is present and recognizable (e.g., org.springframework.boot.loader.WarLauncher)
  2. Optionally, support an env variable like BP_EXECUTABLE_WAR_LOCATION

References

Spring Boot executable WAR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions