eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
775 stars 523 forks source link

jkube 1.17.0 for Java 17 image contains Java 21 bytecode for java.util components #3573

Open robinroos opened 2 days ago

robinroos commented 2 days ago

Describe the bug

We use JKube 1.13.1 targeting Java 17 runtime platform deployment to Open Shift.

When we tried to adopt JKube 1.17.0 the build process worked but the base image seemed to carry with it a Java 21 edition of java.util.

Here are the notes I took:

jkube 1.17.0

oc: spring-boot: Using Docker image quay.io/jkube/jkube-java:0.0.24 as base / builder

application runtime:

2024-10-21 16:00:38.876 ERROR o.g.a.w.WeavingClassFileTransformer - error weaving java/util/WeakHashMap$HashIterator: Unsupported class file major version 65 java.lang.IllegalArgumentException: Unsupported class file major version 65

jkube 1.13.1

build log:

oc: spring-boot: Using Docker image quay.io/jkube/jkube-java:0.0.19 as base / builder

application runtime:

No Exceptions.

Eclipse JKube version

1.17.0

Component

OpenShift Maven Plugin

Apache Maven version

3.6.3

Gradle version

None

Steps to reproduce

<properties>
    <version.jkube>1.17.0</version.jkube>
    <maven.compiler.release>17</maven.compiler.release>
    <kubernetes.trust.certificates>true</kubernetes.trust.certificates>
    <jkube.enricher.jkube-service.type>ClusterIP</jkube.enricher.jkube-service.type>
    <jkube.enricher.jkube-service.normalizePort>false</jkube.enricher.jkube-service.normalizePort>
    <jkube.generator.alias>${project.artifactId}</jkube.generator.alias>
    <jkube.rolling>false</jkube.rolling>
    <jkube.enricher.jkube-controller.replicaCount>2</jkube.enricher.jkube-controller.replicaCount>
    <jkube.build.buildOutput.kind>DockerImage</jkube.build.buildOutput.kind>
    <jkube.generator.name>redacted</jkube.generator.name>
    <jkube.build.pushSecret>redacted</jkube.build.pushSecret>
    <jkube.build.switchToDeployment>true</jkube.build.switchToDeployment>
    <jkube.build.strategy>docker</jkube.build.strategy>
</properties>

Expected behavior

Java 17 base image should not contain Java 21 bytecode.

Runtime

OpenShift

Kubernetes API Server version

1.25.3

Environment

Linux

Eclipse JKube Logs

No issue at build time.

Sample Reproducer Project

I will happily work with you on this as required but cannot submit a reproducer project at this time.

Additional context

Works fine wit JKube 1.13.1, fails at runtime with JKube 1.17.0-generated deployment:

2024-10-21 16:00:38.876 ERROR o.g.a.w.WeavingClassFileTransformer - error weaving java/util/WeakHashMap$HashIterator: Unsupported class file major version 65 java.lang.IllegalArgumentException: Unsupported class file major version 65

manusa commented 2 days ago

Hi Robin, The 17 in the JKube version has nothing to do with the supported Java version. We've been supporting Java 21 almost since the LTS version of Java was released. However, in case your project is not compatible with Java 21, we still maintain a Java 17 image (https://quay.io/repository/jkube/jkube-java-17 / https://github.com/eclipse-jkube/jkube-images/blob/70378958e9aac35963545c52f6c1d3bb192cbefb/jkube-java-17.yaml).

You can switch to use this image just by adding the following property in your Java project:

<jkube.generator.from>quay.io/jkube/jkube-java-17</jkube.generator.from>

That should solve your problem.

Related:

robinroos commented 12 hours ago

Thanks for that.

We chose the alternative approach and I am expediting our adoption of Java 21.