ANTLR dependency conflict geotools-raster and hibernate in geoserver

When using an extension or community module that uses hibernate, there seems to be a strict backward-incompatibility in the ANTLR 4 library.

  1. Hibernate 7 Upgrade: GeoServer recently upgraded to hibernate-core:7.4.5.Final. This version of Hibernate depends on antlr4-runtime:4.13.2. ANTLR 4.13.x serializes its internal Abstract Syntax Trees (ATN) using version 4 of its format.

  2. Jiffle Dependency: GeoTools and GeoServer (specifically the raster processing modules) heavily rely on org.eclipse.imagen:jiffle-language:0.9.2 (the OSGeo Jiffle library). This library was compiled against antlr4-runtime:4.7.1, which uses version 3 of the ATN format.

  3. The Conflict: ANTLR 4 strictly refuses to parse older or newer ATN data.

    • When Tomcat loads the webapp, the classloader picked up the older antlr4-runtime-4.7.1.jar.

    • When Hibernate starts and tries to initialize its parsing lexer, it passes its version 4 ATN data to the version 3 ATNDeserializer from the 4.7.1 jar.

    • The deserializer complains: Could not deserialize ATN with version 4 (expected 3) and crashes the application context.

I can resolve the issue locally by upgrading JIFFLE in geotools. I can make a ticket and PR for this, unless there is a reason not to do this?

Hum… the antlr dependency is actually in ImageN, here:

No objection to an upgrade, just make sure it does not come with visible regressions (behavior, memory usage, performance)

Cheers
Andrea

Hi @Niels, reporting the issue here ANTLR dependency conflict org.eclipse.imagen:jiffle-language: and hibernate-core:7.4.5.Final · Issue #157 · eclipse-imagen/imagen · GitHub if you have an opportunity to work on it.