Commit 415d7827 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

fix executable

parent 2e8c3d83
Loading
Loading
Loading
Loading
Loading
+40
Changes for .changelog/20261015_1605_fix-executable-jar.md: 40 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Fix "no main manifest attribute": build an executable Spring Boot jar

**Date:** 2026-10-15

## Problem
On osl-staging the `gcontroller` pod exited right after printing:
```
Picked up JAVA_TOOL_OPTIONS: -XX:MaxRAMPercentage=75.0
no main manifest attribute, in /app/app.jar
```
`spring-boot-maven-plugin` was declared only under `<build><pluginManagement>`, and the
project does not use `spring-boot-starter-parent` (Spring Boot is imported as a BOM).
Nothing bound the `repackage` goal, so `mvn package` produced a plain ~65 KB jar. Its
manifest had no `Main-Class` and it contained none of the dependencies. The Dockerfile
copies that jar and runs `java -jar`.

## Change
`pom.xml`: a new active `<build><plugins>` entry for `spring-boot-maven-plugin`, with:
- `${spring.boot-version}` as the version, since no parent manages it
- `mainClass` set to `org.etsi.osl.example.gc.ExGCSpringBoot`
- the `repackage` goal

The plain jar is kept as `*.jar.original`. The Dockerfile glob
`org.etsi.osl.examples.gcontroller-*.jar` still matches only the boot jar, so the
Dockerfile is unchanged.

## Verification
- `mvn package`: 119 tests, 0 failures. The jar is ~100 MB.
  - `Main-Class: org.springframework.boot.loader.launch.JarLauncher`
  - `Start-Class: org.etsi.osl.example.gc.ExGCSpringBoot`
  - 264 entries in `BOOT-INF/lib/`
- `java -jar` starts `ExGCSpringBoot`. It then fails to reach Artemis on
  `localhost:61616`, which is expected because no broker runs locally.
- Not done: building the Docker image (the local Docker daemon is not running) and
  redeploying on the cluster.

## Rollout
Push to `develop`. CI rebuilds and pushes `:develop`. Then run
`kubectl -n gcontroller rollout restart deploy/gcontroller`. The addon pins `develop`, so
an Argo CD sync alone does not roll the pod.
+1
Changes for .changelog/index.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

| Doc | Description |
|---|---|
| [20261015_1605_fix-executable-jar.md](20261015_1605_fix-executable-jar.md) | Bind `spring-boot-maven-plugin` `repackage` in `pom.xml`. With no Spring Boot parent it never ran, so the image jar had no `Main-Class` ("no main manifest attribute" on osl-staging). 119 tests pass; the jar starts locally |
| [20261015_1530_restore-weakened-test-assertions.md](20261015_1530_restore-weakened-test-assertions.md) | Re-enable the X.731 header assertions in `ResourceRepoServiceHealthTest` (without `resourceStatus`), drop the vacuous `supersedesAnEarlierConditionVerdict`, re-pin KubernetesCluster's default `operationCostPerHour` and fix its stale javadoc. 119 tests pass. |
| [20261015_1500_dockerfile.md](20261015_1500_dockerfile.md) | Add a runtime-only `Dockerfile` (temurin 17 JRE, non-root) that packages the prebuilt jar, matching the CI `maven_build` → `docker_build` flow, plus a `.dockerignore`. |
| [20261015_1430_why-tests-fail.md](20261015_1430_why-tests-fail.md) | Diagnosis of 25 failing tests: specs stopped declaring `resourceStatus` (20), planning callback no longer sends the `org.etsi.osl.resourceStatus` header (3), and KubernetesCluster cost coefficients were recalibrated without updating its tests (2). No code changed. |
+19
Changes for pom.xml: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -346,6 +346,25 @@
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
			<!-- No spring-boot-starter-parent, so repackage must be bound explicitly:
				without it the jar has no Main-Class and no dependencies. -->
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>${spring.boot-version}</version>
				<configuration>
					<mainClass>org.etsi.osl.example.gc.ExGCSpringBoot</mainClass>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>

	</build>
</project>
 No newline at end of file