Java 22 support
Expected behavior
We use Ebean 15.3.0 and we have troubles upgrading java from 21 to 22 (Azul JDK) We get this error when running tests
io.ebean.config.BeanNotEnhancedException: Bean class com.meetinclass.models.Capacities is not enhanced? Check packages specified in ebean.mf. If you are running in IDEA or Eclipse check that the enhancement plugin is installed. See https://ebean.io/docs/trouble-shooting#not-enhanced
at app//io.ebeaninternal.server.deploy.BeanDescriptorManager.confirmEnhanced(BeanDescriptorManager.java:1234)
at app//io.ebeaninternal.server.deploy.BeanDescriptorManager.setAccessors(BeanDescriptorManager.java:1120)
at app//io.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1049)
at app//io.ebeaninternal.server.deploy.BeanDescriptorManager.registerEmbeddedBean(BeanDescriptorManager.java:586)
at app//io.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityBeanTable(BeanDescriptorManager.java:602)
at app//io.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:274)
at app//io.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:111)
at app//io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:114)
at app//io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:33)
at app//io.ebean.DatabaseFactory.createInternal(DatabaseFactory.java:135)
at app//io.ebean.DatabaseFactory.create(DatabaseFactory.java:84)
Did we miss something?
Probably. Did you go to the url linked in the first line of the error essage - https://ebean.io/docs/trouble-shooting#not-enhanced ? Did you check the things noted on that page wrt maven or gradle? Did you see the enhancement occurring when you build with maven or gradle?
As a side note: If you go to https://github.com/ebean-orm/ebean/actions ... you'll see build actions for:
-
build(Java 11, normal build) -
Multi-JDK Build(Java 11, 17, 21) -
ebean EA(EA, GA, EA Stable) ... and note that today GA is 22, EA is 24-ea and EA Stable is 23-ea.
If you go to one of the ebean EA builds, and look at the maven version you'll see the exact Java version. Right now for GA that is: Java version: 22.0.1
FWIW: Note that the only issues we have hit with any of the JDK EA builds have been related to the Mockito dependency (which relies on bytebuddy) needing to be version bumped or configured to support the JDK EA version. For Ebean we just need to keep up with any new releases of ASM (which is repackaged into ebean-agent for enhancement).
The other thing to note is that Ebean migrated away from anything the JDK deprecated (e.g. finalize() to Cleaner) and also migrated any synchronized to ReentrantLock so that we are 100% good with Virtual Threads. So Ebean is in a good place wrt latest JDK.
Kotlin has put KAPT into maintenance mode so that means that the ebean kotlin-querybean-generator does face the risk of not working as later versions of Kotlin and JDK come out.
Something else to note is that ebean targets Java 11 bytecode and will continue to do so, we might in the future look to require Java 21 to build such that we can support Java 21 SequencedSet & SequencedMap via multi-release jar (which would require the ebean-api module to be built with Java 21). That is, we would still target Java 11 bytecode but need Java 21 to build - see https://github.com/ebean-orm/ebean/pull/3302 (but that means we'd have to adjust how we test against Java 11 and 17)
Thanks for your quick response. I checked the page https://ebean.io/docs/trouble-shooting#not-enhanced, but didn't find a clue here.
I'm getting this error from gradle. So apparently, when I change the JDK version, the enhancement doesn't occure anymore.
With debugLevel = 1, with java 21 :clean then :classes
ebean-agent version:unknown enhancement:143 resources:[META-INF/ebean-version.mf]
ebean-agent version:unknown enhancement:143 resources:[META-INF/ebean-version.mf]
ebean-enhance> loaded resources [META-INF/ebean-version.mf]
ebean-enhance> Entities (28) pkgs[com/meetinclass/models] beans[ArchiveStatusUpdate, Attendance, Capacities, City, Course, DbTimeSlot, Feedback, Message, NotifiedAbsence, PasswordResetToken, Payment, PhoneNumber, Prospect, RememberMeToken, ReportForward, Room, Session, Student, Subscripti ...
ebean-agent version:unknown enhancement:143 resources:[META-INF/ebean-version.mf]
ebean-agent version:unknown enhancement:143 resources:[META-INF/ebean-version.mf]
And with java 22 :clean then :classes
ebean-agent version:unknown enhancement:143 resources:[META-INF/ebean-version.mf]
ebean-agent version:unknown enhancement:143 resources:[META-INF/ebean-version.mf]
ebean-agent version:unknown enhancement:143 resources:[META-INF/ebean-version.mf]
ebean-agent version:unknown enhancement:143 resources:[META-INF/ebean-version.mf]
Here's a build scan https://scans.gradle.com/s/qbpbjxzaq4kue. I don't see bytebuddy in the compile classpath.
Playing with a sample project
I reproduced the case with this sample project https://github.com/ebean-orm/examples/blob/master/basic-gradle-java/build.gradle.
- Upgrade gradle
./gradlew wrapper --gradle-version=8.8 - set
languageVersion = JavaLanguageVersion.of(22)
At this point, enhancement happens
- Remove
options.release = 17or bump to 22
No enhancement anymore.
Probably. Did you go to the url linked in the first line of the error essage - https://ebean.io/docs/trouble-shooting#not-enhanced ? Did you check the things noted on that page wrt maven or gradle? Did you see the enhancement occurring when you build with maven or gradle?
As a side note: If you go to https://github.com/ebean-orm/ebean/actions ... you'll see build actions for:
build(Java 11, normal build)Multi-JDK Build(Java 11, 17, 21)ebean EA(EA, GA, EA Stable) ... and note that today GA is 22, EA is 24-ea and EA Stable is 23-ea.If you go to one of the
ebean EAbuilds, and look at themaven versionyou'll see the exact Java version. Right now for GA that is:Java version: 22.0.1
I have the exact same issue, only thing changed was switching from JDK 21 to JDK 22, with JDK 22 I get no enhancements.
The issue seems to be within the enhancer agent itself, not the rest of the ebean code. https://github.com/ebean-orm/ebean-agent
I did some digging, the enhancement fails due to this code.
https://github.com/ebean-orm/ebean-agent/blob/e3519ebb1898c1e3a08092ef1d1478f81f8624e1/ebean-agent/src/main/java/io/ebean/enhance/asm/ClassReader.java#L197
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V21) {
throw new IllegalArgumentException(
"Unsupported class file major version " + readShort(classFileOffset + 6));
}
So we would need ASM bump to v9.7 https://asm.ow2.io/versions.html ? 🙏
I opened issue in the agent repo https://github.com/ebean-orm/ebean-agent/issues/211
ebean-agent 14.5.0 & 15.5.0 have been released with ASM 9.7 along with the maven and gradle plugins. You can try those.
It works on the new version 👍 Thank you very much