0

I see the following exception when running the code below...

java.lang.IncompatibleClassChangeError: org/opengis/util/InternationalString is not an interface at java.base/java.lang.ClassLoader.defineClassImpl(Native Method) ~[na:na] at java.base/java.lang.ClassLoader.defineClassInternal(ClassLoader.java:481) ~[na:na] at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:442) ~[na:na]

import org.geotools.data.DataUtilities;
import org.geotools.feature.SchemaException;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;
import org.opengis.feature.simple.SimpleFeatureType;
....

    SimpleFeatureType schema = null;
    String srid = "27700";
    try {
        schema = DataUtilities.createType(
                "",
                "Location",
                "locations:Point:srid=" + srid + "," + "id:Integer"
        );
    } catch (SchemaException e) {
        // TODO Auto-generated catch block
        throw new RuntimeException("FUBAR", e);
    }

Why is this interface missing from the repository? And how can I fix this? https://github.com/geotools/geotools/blob/main/modules/library/metadata/src/main/java/org/geotools/util/

I can see that this interface (with the same package) exists within another dependency I use jscience... enter image description here

Versions:

// https://mvnrepository.com/artifact/org.geotools/gt-referencing
implementation group: 'org.geotools', name: 'gt-referencing', version: '25-RC'

// https://mvnrepository.com/artifact/org.geotools/gt-main
implementation group: 'org.geotools', name: 'gt-main', version: '25-RC'

// https://mvnrepository.com/artifact/org.jscience/jscience
implementation group: 'org.jscience', name: 'jscience', version: '4.3.1'

 // https://mvnrepository.com/artifact/org.hibernate/hibernate-spatial (Contains locationtech jts-core@1.18.1)
implementation group: 'org.hibernate', name: 'hibernate-spatial', version: '5.4.30.Final'
Kevvvvyp
  • 1,704
  • 2
  • 18
  • 38
  • At a guess because you haven't imported a referencing implementation (gt-epsg-hsql for example) or you are using an unsupported version of Java (i.e. Not 8 or 11) since gt-main should pull in gt-opengis which contains [InternationalString](https://github.com/geotools/geotools/blob/main/modules/library/opengis/src/main/java/org/opengis/util/InternationalString.java) – Ian Turton Mar 25 '21 at 17:19
  • Oh, and please don't use Datautilities.createType for anything other than toy test cases. It is not a good way to create a schema, use SimpleFeatureTypeBuilder instead – Ian Turton Mar 25 '21 at 17:22
  • jscience seems to replace the InternationString interface that otherwise could come from gt-main -> gt-opengis. Removing jscience seems to fix it. Thanks – Kevvvvyp Mar 25 '21 at 17:27
  • I'm pretty sure JScience shouldn't contain that code – Ian Turton Mar 25 '21 at 17:30
  • see https://stackoverflow.com/questions/60264592/class-conflict-on-different-dependencies – Ian Turton Mar 25 '21 at 17:32
  • It seems to https://javadoc.io/doc/org.jscience/jscience/latest/org/opengis/util/InternationalString.html – Kevvvvyp Mar 25 '21 at 17:58

0 Answers0