Skip to content

Issue 1267 fix: jbp config java main#1268

Open
stokpop wants to merge 5 commits into
cloudfoundry:mainfrom
stokpop:issue-1267-fix-jbp-config-java-main
Open

Issue 1267 fix: jbp config java main#1268
stokpop wants to merge 5 commits into
cloudfoundry:mainfrom
stokpop:issue-1267-fix-jbp-config-java-main

Conversation

@stokpop
Copy link
Copy Markdown
Contributor

@stokpop stokpop commented May 11, 2026

Also added some notes on why the integration test did not find the missing arguments and command line changes.

Fixes #1267

stokpop added 5 commits May 11, 2026 10:50
…ring Boot

The registry stopped at Spring Boot (highest priority) without ever calling
JavaMainContainer.Detect(). If java_main_class is set in JBP_CONFIG_JAVA_MAIN,
select Java Main unconditionally before the normal detection loop, so it can
override higher-priority containers such as Spring Boot.

Also adds Ruby parity for SERVER_PORT: when java_main_class is a Spring Boot
launcher (JarLauncher, PropertiesLauncher, WarLauncher), write SERVER_PORT=$PORT
to profile.d so the app binds to the CF-assigned port.

Example use case:
  JBP_CONFIG_JAVA_MAIN: '{java_main_class: "org.springframework.boot.loader.launch.PropertiesLauncher", arguments: "--loader.home=/home/vcap/data"}'

Updates container-java_main.md: references JBP_CONFIG_JAVA_MAIN instead of
config/java_main.yml, corrects SERVER_PORT behaviour, adds example.
@stokpop stokpop changed the title Issue 1267 fix jbp config java main Issue 1267 fix: jbp config java main May 15, 2026
Copy link
Copy Markdown
Contributor

@kiril-keranov kiril-keranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, left minor suggestion for possible optimization

func (r *Registry) Detect() (Container, string, error) {
cfg := loadJavaMainConfig(r.context.Log)
if cfg.JavaMainClass != "" {
for _, container := range r.containers {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems this loop might be omit if we rely on the current order that the java main container is with least priority like currently here. If for some reason these container priorities change or a new container is introduced after the java main there will be failing tests like selects Java Main container instead of Spring Boot signaling this to change, also seems no major container priorities reordering or addition of new containers are expected I guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JBP_CONFIG_JAVA_MAIN java_main_class and arguments not supported

2 participants