I want to export a SimpleFeatureCollection (Read from a MySQL DB) to a KML file, here is my code used to read the infos into the console:

private void featureCollectionToKML(SimpleFeatureCollection features)
        throws Exception {

    Encoder encoder = new Encoder(new KMLConfiguration());
    encoder.encode(features, KML.kml, System.out);

When I run the program there are first some WARNINGS when I get the Features and then the program crashes with this error log:

PM org.geotools.referencing.factory.PropertyAuthorityFactory

WARNING: Axis elements found in a wkt definition, the force longitude first axis order hint might not be respected: PROJCS["Google Projection",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],UNIT["degree", 0.017453292519943295],AXIS["Geodetic longitude", EAST],AXIS["Geodetic latitude", NORTH],AUTHORITY["EPSG","4326"]],PROJECTION["Popular Visualisation Pseudo Mercator", AUTHORITY["EPSG","1024"]],PARAMETER["semi_minor", 6378137.0],PARAMETER["latitude_of_origin", 0.0],PARAMETER["central_meridian", 0.0],PARAMETER["scale_factor", 1.0],PARAMETER["false_easting", 0.0],PARAMETER["false_northing", 0.0],UNIT["m", 1.0]]

ott 23, 2013 4:06:49 PM org.geotools.feature.simple.SimpleFeatureTypeBuilder add

WARNING: Creating LookAt with null CoordinateReferenceSystem - did you mean to setCRS?

ott 23, 2013 4:06:49 PM org.geotools.feature.simple.SimpleFeatureTypeBuilder add

WARNING: Creating Region with null CoordinateReferenceSystem - did you mean to setCRS? java.lang.RuntimeException: Failed to get property: id at org.geotools.xml.impl.GetPropertyExecutor.visit(GetPropertyExecutor.java:105) at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:220) at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:186) at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:47) at org.geotools.xml.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:32) at org.geotools.xml.Encoder.encode(Encoder.java:902) at org.geotools.xml.Encoder.encode(Encoder.java:603) at shapefileManager.ShapefileManager.featureCollectionToKML(ShapefileManager.java:173) at shapefileManager.ShapefileManager.convertArchiToFeatuesKML(ShapefileManager.java:114) at Main.Test.main(Test.java:19) Caused by: java.lang.UnsupportedOperationException at org.geotools.data.store.ContentFeatureCollection.getID(ContentFeatureCollection.java:492) at org.geotools.kml.bindings.FeatureTypeBinding.getProperty(FeatureTypeBinding.java:284) at org.geotools.xml.impl.GetPropertyExecutor.visit(GetPropertyExecutor.java:103) ... 9 more

I can't understand which is the problem...

Here is how I get the SimpleFeaturesCollection from MySQL DB

 public void convertArcsToFeatuesKML(String[] ids) {

    try {

        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

        Set<FeatureId> fids = new HashSet<FeatureId>();

        for (int i = 0; i < ids.length; i++) {



        Filter filter = ff.id(fids);

        SimpleFeatureCollection features = featureSource


    } catch (Exception e) {             e.printStackTrace();        } 

FeatureSource is the MySQL DB.

PS I've checked, with the getId() method, and all features have an unique ID.

  • Looks like you don't have an ID defined - can you print out a couple of features before you call toKML – Ian Turton Oct 23 '13 at 14:28
  • I've printed feature.getId() and all have one. – Felix Oct 23 '13 at 17:05
  • Your features don't have a CRS set, you need to fix the database tables – Ian Turton May 15 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.