1

I've tried to create several types of GeoServer layer stylings with basic labels, both in SLD and via the GeoServer CSS extension. Yet, not once have I managed to get the labels actually rendered. Everything else renders as it should.

I'm running GeoServer 2.11 on Centos 7 (had the same issue on GS 2.9 as well). Data's coming from PostgreSQL 9.2.15 (64-bit, UTF-8 encoded databases).

For instance trying to create a simple polygon style with attribute-based labels in CSS:

* {
  fill: #95C8C1;
  label: [field];
  font-fill: #000000;
  font-family: Arial;
  font-size: 7;
  font-style: normal;
  label-anchor: 0.5 0.5;
}

I've checked for all possible field name letter size matches vs. the data, and also non-field based labels, but nothing.

Similar styling in SLD, also does not render labels:

<StyledLayerDescriptor 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" version="1.0.0" 
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>Polygon styling test</Name>
 <UserStyle>
  <FeatureTypeStyle>
    <Rule>
      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#95C8C1</CssParameter>
        </Fill>
      </PolygonSymbolizer>
      <TextSymbolizer>
        <Label>
          <ogc:PropertyName>field</ogc:PropertyName>
        </Label>
        <Font>
          <CssParameter name="font-family">Arial</CssParameter>
          <CssParameter name="font-style">normal</CssParameter>
          <CssParameter name="font-size">7</CssParameter>
        </Font>
        <Fill>
          <CssParameter name="fill">#000000</CssParameter>
        </Fill>
      </TextSymbolizer>
    </Rule>
   </FeatureTypeStyle>
  </UserStyle>
 </NamedLayer>
</StyledLayerDescriptor>

I've tried fiddling around with GeoServer VendorOptions (ConflictResolution etc.), but those break my stylings completely and layers fail to display. Also enabled/disabled caching, reset options, emptied caches, tried different gutters, etc., but nothing.

The only hint I've encountered so far is in the GeoServer logs:

at java.lang.Thread.run(Thread.java:745)
ERROR [renderer.label] - Error adding label to the label cache
java.lang.NullPointerException

Any idea on what is the underlying reason for all this? Is Java getting Null values for the label for some reason?

2
  • are you sure you have an attribute called exactly field in your layer? check on the layer data page which will show you the attributes
    – Ian Turton
    Commented Apr 25, 2017 at 11:01
  • The field name "field" was here only for illustrative purposes, but yes, I've checked the actual attribute name against the layer data.
    – Alec Acorn
    Commented Apr 25, 2017 at 11:45

1 Answer 1

2

The problem was finally found, under the hood...

After trying a bunch of different usual suspect fonts, started to wonder why the fc-list command returned no information - there were absolutely no fonts installed on the server!

Since I needed to use a bunch of specific MS fonts, this seemed to do the trick:

wget http://www.itzgeek.com/msttcore-fonts-2.0-3.noarch.rpm
rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm

Or a different approach via yum:

yum install curl cabextract xorg-x11-font-utils fontconfig
yum install 
https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-
installer-2.6-1.noarch.rpm

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.