When requesting the legend graphic in application/json format like this:
wms?service=WMS&version=1.3.0&request=GetLegendGraphic&layer={layername}&format=application/json
A NullPointerException like the one below will appear when the style attached to the layer has a TextSymbolizer in one of the rules, where some of the default properties are left out (which is allowed, the style does work on the getMap requests). This is in SLD style format
When all properties are explicitly put in the style, the endpoint works correctly.
Example where it goes wrong:
<se:Rule>
<se:Name>label</se:Name>
<se:Description>
<se:Title>label</se:Title>
</se:Description>
<se:TextSymbolizer>
<se:Label>
<ogc:PropertyName>spot_number</ogc:PropertyName>
</se:Label>
<se:Font>
<se:SvgParameter name="font-family">MS Shell Dlg 2</se:SvgParameter>
<se:SvgParameter name="font-size">12</se:SvgParameter>
</se:Font>
<se:LabelPlacement>
<se:PointPlacement>
<se:AnchorPoint>
<se:AnchorPointX>0.5</se:AnchorPointX>
<se:AnchorPointY>0.5</se:AnchorPointY>
</se:AnchorPoint>
</se:PointPlacement>
</se:LabelPlacement>
</se:TextSymbolizer>
</se:Rule>
Example where it goes right:
<se:Rule>
<se:Name>label</se:Name>
<se:Description>
<se:Title>label</se:Title>
</se:Description>
<se:TextSymbolizer>
<se:Label>
<ogc:PropertyName>spot_number</ogc:PropertyName>
</se:Label>
<se:Font>
<se:SvgParameter name="font-family">MS Shell Dlg 2</se:SvgParameter>
<se:SvgParameter name="font-size">12</se:SvgParameter>
</se:Font>
<se:LabelPlacement>
<se:PointPlacement>
<se:AnchorPoint>
<se:AnchorPointX>0.5</se:AnchorPointX>
<se:AnchorPointY>0.5</se:AnchorPointY>
</se:AnchorPoint>
<se:Rotation>0</se:Rotation>
</se:PointPlacement>
</se:LabelPlacement>
<se:Fill>
<se:CssParameter name="fill">#990099</se:CssParameter>
<se:CssParameter name="opacity">1</se:CssParameter>
</se:Fill>
</se:TextSymbolizer>
</se:Rule>
I’ve seen it happen on <Rotation> and <Fill> -> cssprop fill/<Fill> ->cssprop opacity
java.lang.NullPointerException
at org.geoserver.wms.legendgraphic.JSONLegendGraphicBuilder.toJSONValue(JSONLegendGraphicBuilder.java:411)
at org.geoserver.wms.legendgraphic.JSONLegendGraphicBuilder.processTextSymbolizer(JSONLegendGraphicBuilder.java:872)
at org.geoserver.wms.legendgraphic.JSONLegendGraphicBuilder.processSymbolizer(JSONLegendGraphicBuilder.java:809)
at org.geoserver.wms.legendgraphic.JSONLegendGraphicBuilder.buildLegendGraphic(JSONLegendGraphicBuilder.java:359)
at org.geoserver.wms.legendgraphic.JSONLegendGraphicBuilder.buildLegendGraphic(JSONLegendGraphicBuilder.java:81)
at org.geoserver.wms.legendgraphic.JSONLegendOutputFormat.produceLegendGraphic(JSONLegendOutputFormat.java:40)
at org.geoserver.wms.legendgraphic.JSONLegendOutputFormat.produceLegendGraphic(JSONLegendOutputFormat.java:20)
|