[Geoserver-users] NoSuchMethodError running GeoServer 2.22.5 WAR with JDK8

I was upgrading from GeoServer 2.22.4 to 2.22.5 using the Web Archive (WAR) package and deploying in JDK8 and encountered a NoSuchMethodError related to compiling the GeoTools JARs with JDK11. I was able to reproduce the error using the unmodified WAR directly from the download site and the default data directory (stack trace is at the end).

I looked at the MANIFEST.MF files in the GeoTools 28.5 JARs in the WAR and they say “Build-Jdk-Spec: 11” but the GeoTools 28.5 JARs in the OSGeo Nexus repo say “Build-Jdk-Spec: 1.8” and I was able to confirm that replacing the affected GeoTools JARs with the Nexus version ran fine with JDK8.

MANIFEST.MF from the gt-shapefile-28.5.jar in Download geoserver-2.22.5-war.zip (GeoServer)
Build-Jdk-Spec: 11
Build-Timestamp: 30-Aug-2023 08:29
Git-Revision: e932a443b6e51756ebf1261baab4c0c390706ece

MANIFEST.MF from https://repo.osgeo.org/repository/release/org/geotools/gt-shapefile/28.5/gt-shapefile-28.5.jar
Build-Jdk-Spec: 1.8
Build-Timestamp: 31-Aug-2023 12:31
Git-Revision: 53833690070eb6af1b283ab278e6da4267be3cac

These are the GeoTools modules that directly use java.nio.ByteBuffer with main, metadata, referencing and shapefile being included in the core package:
library/main
library/metadata
library/referencing
plugin/grassraster
plugin/jdbc/jdbc-hana
plugin/shapefile
unsupported/flatgeobuff
unsupported/geobuff
unsupported/s3-geotiff

I don’t know if this is serious enough to consider doing another “final” 2.22.x release when a developer becomes available. If not, a note should be added somewhere that JDK8 users will need to either stay on GeoServer 2.22.4 or use the workaround of manually replace certain GeoTools JARs if they are using GeoServer in a way that triggers these errors.

Stack Trace:
2023-09-05 15:38:39,662 ERROR [org.geoserver] Failed to run initializer org.geoserver.gwc.config.GWCInitializer@anonymised.com: java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
at org.geotools.data.shapefile.dbf.DbaseFileHeader.readHeader(DbaseFileHeader.java:577)
at org.geotools.data.shapefile.dbf.DbaseFileReader.doInit(DbaseFileReader.java:226)
at org.geotools.data.shapefile.dbf.DbaseFileReader.init(DbaseFileReader.java:186)
at org.geotools.data.shapefile.dbf.DbaseFileReader.(DbaseFileReader.java:148)
at org.geotools.data.shapefile.ShapefileSetManager.openDbfReader(ShapefileSetManager.java:132)
at org.geotools.data.shapefile.ShapefileFeatureSource.readAttributes(ShapefileFeatureSource.java:497)
at org.geotools.data.shapefile.ShapefileFeatureSource.buildFeatureType(ShapefileFeatureSource.java:454)
at org.geotools.data.shapefile.ShapefileFeatureStore.buildFeatureType(ShapefileFeatureStore.java:142)
at org.geotools.data.store.ContentFeatureSource.getAbsoluteSchema(ContentFeatureSource.java:339)
at org.geotools.data.store.ContentFeatureSource.getSchema(ContentFeatureSource.java:308)
at org.geotools.data.store.ContentDataStore.getSchema(ContentDataStore.java:295)
at org.geotools.data.directory.DirectoryDataStore.getSchema(DirectoryDataStore.java:106)
at org.geotools.data.directory.DirectoryDataStore.getSchema(DirectoryDataStore.java:178)
at org.geotools.data.directory.DirectoryDataStore.getSchema(DirectoryDataStore.java:50)
at org.geoserver.catalog.ResourcePool.acquireFeatureType(ResourcePool.java:1012)
at org.geoserver.catalog.ResourcePool.getCacheableFeatureType(ResourcePool.java:994)
at org.geoserver.catalog.ResourcePool.tryGetFeatureType(ResourcePool.java:977)
at org.geoserver.catalog.ResourcePool.getFeatureType(ResourcePool.java:960)
at org.geoserver.catalog.ResourcePool.getFeatureType(ResourcePool.java:954)
at org.geoserver.catalog.ResourcePool.loadAttributes(ResourcePool.java:841)
at org.geoserver.catalog.ResourcePool.attributeTypeInfos(ResourcePool.java:825)
at org.geoserver.catalog.ResourcePool.getAttributes(ResourcePool.java:815)
at org.geoserver.catalog.impl.FeatureTypeInfoImpl.attributes(FeatureTypeInfoImpl.java:129)

Steve Ikeoka

Steve,

Oh no! Peter (CCed) did ask that the release artifacts be tested before being made available. We may have to regenerate the release :(​

···

It is worth doing another release, as this is a problem with the build environment rather than with the software tag.

Jody Garnett

Steve:

I can confirm the errors:

05 Sep 20:34:18 ERROR [org.geoserver] - Failed to run initializer org.geoserver.gwc.config.GWCInitializer@anonymised.com

java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;

at org.geotools.data.shapefile.dbf.DbaseFileHeader.readHeader(DbaseFileHeader.java:577)

···

I have restored the build process using java 8 jobs on the build server and the resulting artifacts are working in Java 8 environment.

Build Information

GeoServer Version
2.22.5
Git Revision
487dc9c843d566db9435458ebb06c9a08ca70283
Build Date
06-Sep-2023 03:15
GeoTools Version
28.5 (rev 14d52ac359991917312803c20ae65df981e903fd)
GeoWebCache Version
1.22.2 (rev 1.22.x/7f2cc58279e2f8ee73f5e5ca04897850e8e004f6)

I have re-deployed to source forge, please download and and confirm everything is working for you.

Thanks for reporting the problem, often problems like this are “so obvious” everyone thinks it has been noticed already. I made sure to thank you in the updated re-release announcement.


Jody Garnett

It is worth doing another release, as this is a problem with the build environment rather than with the software tag.

Jody Garnett

Thank you very much Steve for reporting the problem.

And thank you also to Jody for fixing the build server and re-releasing it.

Please take note of the update: https://geoserver.org/announcements/2023/08/30/geoserver-2-22-5-released.html

Peter

···

I have restored the build process using java 8 jobs on the build server and the resulting artifacts are working in Java 8 environment.

Build Information

GeoServer Version
2.22.5
Git Revision
487dc9c843d566db9435458ebb06c9a08ca70283
Build Date
06-Sep-2023 03:15
GeoTools Version
28.5 (rev 14d52ac359991917312803c20ae65df981e903fd)
GeoWebCache Version
1.22.2 (rev 1.22.x/7f2cc58279e2f8ee73f5e5ca04897850e8e004f6)

I have re-deployed to source forge, please download and and confirm everything is working for you.

Thanks for reporting the problem, often problems like this are “so obvious” everyone thinks it has been noticed already. I made sure to thank you in the updated re-release announcement.


Jody Garnett

It is worth doing another release, as this is a problem with the build environment rather than with the software tag.

Jody Garnett