1

This is a follow-up to Geoserver cannot find style in external SLD file.

I have an external SLD file (dynamically created by and ASP) which starts as follows

<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" 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 http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
    <Name>Local:PandMetScore</Name>
        <UserStyle>
            <Title>default</Title>
            <Abstract>polygonen voor PandMetScore</Abstract>
            <FeatureTypeStyle>
                <Rule>
                    <Name>1 t/m 3.5</Name>
                    <Title>Lager dan of gelijk aan 3.5</Title>
                    <Abstract/>
                    <ogc:Filter>
                        <ogc:PropertyIsLessThanOrEqualTo>
                            <ogc:PropertyName>Gemiddeld</ogc:PropertyName>
                            <ogc:Literal>3.5</ogc:Literal>
                        </ogc:PropertyIsLessThanOrEqualTo>
                    </ogc:Filter>
                    <PolygonSymbolizer>
                        <Fill>
                            <CssParameter name="fill">#F00000</CssParameter>
                            <CssParameter name="fill-opacity">1</CssParameter>
                        </Fill>
                        <Stroke>
                            <CssParameter name="stroke">#FFFFFF</CssParameter>
                            <CssParameter name="stroke-width">0</CssParameter>
                        </Stroke>
                    </PolygonSymbolizer>
                </Rule>

I try to perform a GetMap request for a WMS tile layer using this SLD file with http://localhost:8080/geoserver/Local/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&SLD=http%3A%2F%2Fgprvapp.localtest.me%2FHome%2FGetSld%2FPandMetScore%2FGemiddeld&WIDTH=256&HEIGHT=256&CRS=EPSG%3A28992&BBOX=136936.64%2C456548.79999999993%2C137366.72%2C456978.87999999995

I do this with OpenLayers 3, the layer is created with

var tileWms = new ol.source.TileWMS({
            url: geoserverWms,
            params: {
                'TRANSPARENT': true,
                'FORMAT': "image/png",
                'SLD': sldUrl,
                'CQL_FILTER': cqlFilter
            },
            serverType: "geoserver"
        });

sldUrl is off course defined as you can see in the GetMap request.

But Geoserver seems to be unable to find the layer, I get this error message:

    Request: getServiceInfo
2017-02-10 09:42:24,921 DEBUG [org.geoserver.ows] - Getting layers and styles from reomte SLD
2017-02-10 09:42:24,926 DEBUG [org.vfny.geoserver.requests] - First 4 bytes of XML doc are : 3C ('<') 3F ('?') 78 ('x') 6D ('m')
2017-02-10 09:42:24,926 DEBUG [org.vfny.geoserver.requests] - Charset detection phase 1. Inferred encoding: UTF-8
2017-02-10 09:42:24,927 DEBUG [org.vfny.geoserver.requests] - Charset detection phase 2. Charset in XML declaration is `UTF-8`.
2017-02-10 09:42:24,928 DEBUG [org.vfny.geoserver.requests] - Trying to create reader basing on existing charset information: `UTF-8`.
2017-02-10 09:42:24,935 WARN [org.geoserver.ows] - Exception while getting SLD.
org.geoserver.platform.ServiceException: Unknown layer: PandMetScore 
    at org.geoserver.wms.map.GetMapKvpRequestReader.processStandaloneSld(GetMapKvpRequestReader.java:850)
    at org.geoserver.wms.map.GetMapKvpRequestReader.processSld(GetMapKvpRequestReader.java:689)
    at org.geoserver.wms.map.GetMapKvpRequestReader.read(GetMapKvpRequestReader.java:343)
    at org.geoserver.wms.map.GetMapKvpRequestReader.read(GetMapKvpRequestReader.java:85)
    at org.geoserver.ows.Dispatcher.parseRequestKVP(Dispatcher.java:1498)
    at org.geoserver.ows.Dispatcher.dispatch(Dispatcher.java:673)
    at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:258)
    at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:147)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:436)
    at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:177)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:28)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:75)
    at org.geoserver.wms.animate.AnimatorFilter.doFilter(AnimatorFilter.java:71)
    at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:71)
    at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:46)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:50)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
    at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
    at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:158)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
    at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
    at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:84)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
    at org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1.doFilter(GeoServerSecurityContextPersistenceFilter.java:53)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
    at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
    at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:152)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:87)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:42)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:48)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.geoserver.filters.FlushSafeFilter.doFilter(FlushSafeFilter.java:44)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

I also get this error when I do not set the environment name in front of the layername as PandMetScore instead of Local:PandMetScore.

The layer Title is PandMetScore, the layer name is Local:PandMetScore in the Geoserver.

Running Geoserver 2.10.1 on Tomcat 8.0.32

  • 1
    does it work if you use localhost:8080/geoserver/wms? and then reference your layer with Local: . Also do you want to specify style=default& if you are specifying an external SLD, you don't need to specify either Layer& or style& in a WMS GetMap request if using an SLD& – nmtoken Feb 10 '17 at 8:58
  • getting the layer with a catalog style works for both with and without the Environment name and you are correct, I do not need to include the style name, but it doesn't work regardless (I will edit my question to leave it out) – Daniël Tulp Feb 10 '17 at 9:13
  • if you don't name the style to be used you need a <IsDefault/> tag in UserStyle – Ian Turton Feb 10 '17 at 9:34
  • <IsDefault/> is only for Library mode and I do not want Library mode see docs.geoserver.org/stable/en/user/styling/sld/reference/… – Daniël Tulp Feb 10 '17 at 9:35
  • Is it a character encoding issue? – nmtoken Feb 10 '17 at 13:21
2

I've confirmed the general machinery works by running the following request on my local GeoServer instance:

http://localhost:8080/geoserver/wms?bbox=-130,24,-66,50&Format=image/png&request=GetMap&width=550&height=250&srs=EPSG:4326&SLD=http://localhost/illinois.sld

where the style is:

<StyledLayerDescriptor version="1.0.0">
<NamedLayer>
    <Name>topp:states</Name>
    <UserStyle>
      <Name>UserSelection</Name>
      <FeatureTypeStyle>
        <Rule>
          <Filter xmlns:gml="http://www.opengis.net/gml">
            <PropertyIsEqualTo>
              <PropertyName>STATE_NAME</PropertyName>
              <Literal>Illinois</Literal>
            </PropertyIsEqualTo>
          </Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#FF0000</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>
        <Rule>
          <LineSymbolizer>
            <Stroke />
          </LineSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Now, tried to find why it does not work for you by looking at the code. By that stack trace I can figure that:

  • The SLD got parsed correctly
  • The name of the layer has been picked up also correctly
  • GeoServer cannot really find that layer when doing the lookup in the catalog

Possible ideas for it:

  • A simple typo in the layer name (names are case sensitive, for example)
  • A security rule preventing the anonymous user from accessing that layer (in the default HIDE mode GeoServer will claim the layer is not there, not that you're not authorized to get it, in case of doubt switch to MIXED mode and you'll get an authentication challenge)
  • Possibly a bug that's manifesting on your particular setup (if this is the case, best switch to the GeoServer users mailing list, stackexchange is not a good place for extended conversations)
  • thank you for making a real effort in helping me, plus one for that no matter the outcome. The name of the layer is Local:PandMetScore (copied from the catelog list of all layers), so a typo appears not to be the reason for failing to get the layer. I think I have set it to MIXED mode using *.*.r=*[mode=mixed] in the layers.properties file (as per docs.geoserver.org/stable/en/user/security/…) – Daniël Tulp Feb 13 '17 at 7:44
  • o, sorry, forgot to include the outcome ;), same result however – Daniël Tulp Feb 13 '17 at 12:25
  • aaaaah, figured it out, it was a trailing space behind the name, and of course geoserver couldn't find Local:PandMetScore . The problem wasn't visible when I opened the SLD in Google Chrome. When I told GC to 'view source' the space was visible. Apparently the XML representation in GC has some styling over it that hides leading and trailing spaces within elements. Thank you Google! – Daniël Tulp Feb 13 '17 at 12:51

Your Answer

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

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