#2298 closed defect (fixed)

BASE doesn't work with Java versions >18

Reported by: Nicklas Nordborg Owned by: everyone
Priority: major Milestone: BASE 3.19.8
Component: core Version:
Keywords: Cc:

Description

We have tested BASE with Java 18 and it seems to work. However it fails with Java 19 and 20 with a very long stacktrace on the login page in the web client.

The start of the stacktrace:

net.sf.basedb.core.BaseException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
  at net.sf.basedb.core.HibernateUtil.init2(HibernateUtil.java:264)
  at net.sf.basedb.core.Application.start(Application.java:515)
  at net.sf.basedb.clients.web.servlet.StartStopServlet.contextInitialized(StartStopServlet.java:56)
...

There are a lot of Caused by... entries until the final one:

Caused by: java.lang.UnsupportedOperationException: Could not access Unsafe class: 
sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
  at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Unavailable.initialize(ClassInjector.java:2061)
  at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.injectRaw(ClassInjector.java:1793)
  at net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.inject(ClassInjector.java:113)
  at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$ForUnsafeInjection.load(ClassLoadingStrategy.java:567)
  at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:100)
  at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6154)
  at org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.lambda$load$0(ByteBuddyState.java:182)
  at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:153)

It seems to be an issue with ByteBuddy. We are using version 1.11.8. The latest one is 1.14.2. The changelog for version 1.12.9 has an interesting entry: Add support for Java 19 https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.12.9

It might be possible to update ByteBuddy directly, but it may affect Hibernate. We are using Hibernate 5.5.6 but the latest of the 5.x-series is 5.6.15. It might be better to check if updating Hibernate solves the issue (although Hibernate only claims compatibility with Java 11, 17 and 18 also for Hibernate 6.x).

Change History (4)

comment:1 by Nicklas Nordborg, 13 months ago

I have tested to just replace the Hibernate and ByteBuddy JAR files with those from version 5.6.15 and 1.12.23 and the login now works with Java 20. Need to test it with compilation and all test programs as well, but it looks promising.

comment:2 by Nicklas Nordborg, 13 months ago

In 8133:

References #2298: BASE doesn't work with Java versions >18

Updated to Hibernate 5.6.15 and ByteBuddy 1.12.23.

Compilation and installation work. There are some warnings about deprecation left. Test programs have not been tested yet.

comment:3 by Nicklas Nordborg, 13 months ago

In 8134:

References #2298: BASE doesn't work with Java versions >18

Fixed remaining warnings. Test programs seems to be working fine.

comment:4 by Nicklas Nordborg, 13 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.