I have a layer in GeoServer which is stored in a PostGIS database. The geometrytype of the layer is GEOMETRY and now the table only contains LINESTRING. But I what to add points and polygons to the table, this is the reason I choose GEOMETRY as the geometrytype. My layer is working fine in the Layer Preview...

But when I do a GetLegendGraphic request I get the following ServiceException: java.lang.IllegalArgumentException: class com.vividsolutions.jts.geom.Geometry is not supported by this method class com.vividsolutions.jts.geom.Geometry is not supported by this method

My SLD is quite simple:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
     <CssParameter name="stroke">#FFA618</CssParameter>
     <CssParameter name="stroke-width">2</CssParameter>
     <CssParameter name="stroke-dasharray">5 2</CssParameter>

My GetLegendGraphic request is:

I have tried the request on a GeoServer 2.0.1 and a GeoServer 2.0.2 and in both cases I get ServiceException as above mentioned.

What can I do to get the request working?

2 Answers 2


I found out that my geometry column had a not-null constraint in PostGIS. When I removed the not-null constraint I got rid of the GetLegendGraphic request ServiceException.

Another solution to get rid of the GetLegendGraphic request ServiceException was to change the geometrytype in PostGIS from GEOMETRY TO LINESTRING (change the type in the table geometry_columns), but that is not a valid option in my case.


You need a filter something like:

      <ogc:Function name="geometryType">

in the rule you would like to style the lines.

See http://docs.geoserver.org/2.0.0/user/styling/sld-tipstricks/mixed-geometries.html for a fuller discussion of how to handle multiple geometry types in the same table.

  • 1
    My filter only selects the lines as the all have the value 'test'. But I have tried using geometryType filter and I still get the same ServiceException. I have another layer where I have points, lines and polygons.This layer are shown fine (all the geometrytypes are drawn) when I style the layer, but the GetLegendGraphic request still fails...
    – taudorf
    Commented Oct 6, 2010 at 14:23
  • could be a bug then.
    – Ian Turton
    Commented Oct 6, 2010 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.