2

I'm running up against an issue getting a NullPointerException when I enable GeoServer GWC WMS Direct Integration then request a layer using the SLD_BODY request parameter (e.g. without a LAYERS param).

This happens regardless of the content of the SLD_BODY, regardless of which layer is requested in the SLD and even when tile caching is disabled for the layer requested. When I drop the SLD_BODY in favor of a LAYERS parameter everything goes back to normal.

As soon as I turn the direct integration off, this issue goes away.

Anybody have any idea what might be going on here? Is SLD_BODY just not supported when GWC Direct Integration is enabled?

Details are below.

Example Request: http://localhost:8080/geoserver/wms?service=wms&version=1.1.0&REQUEST=GetMap&FORMAT=image/png&TILED=true&WIDTH=256&HEIGHT=256&SRS=EPSG:900913&TRANSPARENT=true&bbox=-13149614.849955441,3991847.365165045,-13139830.910334937,4001631.3047855473&viewparams=ids:3%5C,24%5C,5%5C,6%5C;year:2002;&sld_body=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3CStyledLayerDescriptor%20version%3D%221.0.0%22%20%0Axsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%20StyledLayerDescriptor.xsd%22%20%0Axmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22%20%0Axmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%20%0Axmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20%0Axmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%3E%0A%3CNamedLayer%3E%0A%3CName%3Ecities%3C%2FName%3E%0A%3CUserStyle%3E%0A%3CTitle%3EDefault%20Point%3C%2FTitle%3E%0A%3CAbstract%3EA%20sample%20style%20that%20draws%20a%20point%3C%2FAbstract%3E%0A%3CFeatureTypeStyle%3E%0A%3CRule%3E%0A%3CName%3Erule1%3C%2FName%3E%0A%3CTitle%3ERed%20Square%3C%2FTitle%3E%0A%3CAbstract%3EA%206%20pixel%20square%20with%20a%20red%20fill%20and%20no%20stroke%3C%2FAbstract%3E%0A%3CPointSymbolizer%3E%0A%3CGraphic%3E%0A%3CMark%3E%0A%3CWellKnownName%3Esquare%3C%2FWellKnownName%3E%0A%3CFill%3E%0A%3CCssParameter%20name%3D%22fill%22%3E%23FF0000%3C%2FCssParameter%3E%0A%3C%2FFill%3E%0A%3C%2FMark%3E%0A%3CSize%3E6%3C%2FSize%3E%0A%3C%2FGraphic%3E%0A%3C%2FPointSymbolizer%3E%0A%3C%2FRule%3E%0A%3C%2FFeatureTypeStyle%3E%0A%3C%2FUserStyle%3E%0A%3C%2FNamedLayer%3E%0A%3C%2FStyledLayerDescriptor%3E%0A%0A

Results in: https://pastebin.com/yCsMPffg

UPDATE I fully agree with @iant, @nmtoken and @Andrea Aime and using an SLD_BODY in a cached layer is somewhat backwards. The problem is that even turning off caching wholesale for the layers you want to use an SLD_BODY it still throws this error. Honestly, a way to tell Geoserver to just process this request as a standard WMS request for this layer would be a perfectly acceptable solution to my immediate problem. However, I can't seem to find a way to do so.

Decoded SLD Request:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" 
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
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">
<NamedLayer>
<Name>cities</Name>
<UserStyle>
<Title>Default Point</Title>
<Abstract>A sample style that draws a point</Abstract>
<FeatureTypeStyle>
<Rule>
<Name>rule1</Name>
<Title>Red Square</Title>
<Abstract>A 6 pixel square with a red fill and no stroke</Abstract>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>square</WellKnownName>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
</Fill>
</Mark>
<Size>6</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

Relevant Log Exception Excerpt: java.lang.NullPointerException at org.geoserver.gwc.GWC.dispatch(GWC.java:668) at org.geoserver.gwc.wms.CachingWebMapService.invoke(CachingWebMapService.java:84) at org.geoserver.gwc.wms.CachingWebMapService.invoke(CachingWebMapService.java:55)

Based what I can tell from the stack trace (fully admitting I am neither a Java guy nor a Geoserver expert), when GWC direct integration is enabled, it uses the CachingWebMapService class which calls GWC.dispatch.ConveyorTile, this does some checks for a LAYERS parameter and when there isn't one, it throws.

7
  • 1
    I removed thanks in advance from your question. Please show thanks by voting for any answer you get
    – nmtoken
    Commented Jul 14, 2017 at 6:15
  • 2
    I suspect that the ability to change the styling of a layer goes against the idea of caching. caching implies static content (predefined styles). If you want dynamic content you probably need to use the WMS.
    – nmtoken
    Commented Jul 14, 2017 at 6:56
  • if you could add the SLD un-urlencoded and formatted it would be easier to see if there is an error there. While linking to the full log is good, just including the first few lines that show what and where the error is would be even better.
    – Ian Turton
    Commented Jul 14, 2017 at 7:58
  • 2
    I'd also add the full stack trace. There is a good chance it's a bug, as @iant said, caching and dynamic styling do not really go hand in hand, it's an odd combination (although admittedly a legit one) Commented Jul 14, 2017 at 8:13
  • Appreciate the input everyone. I've updated the question with the additional details you've asked for. If I missed anything, just let me know and I'll get it handled.
    – mikeo
    Commented Jul 14, 2017 at 16:56

1 Answer 1

4

For the time being I have a couple workarounds to this problem:

  1. Don't use GWC Direct Integration if any layer will ever need to accept an sld_body or sld parameter. Work around this by leaving Direct Integration turned off and write code on the front-end to determine if a layer/request is "cache-eligible" (e.g. no sld/sld_body) and if so, change it's tile request endpoint from WMS to GWC/WMTS/TMS.
  2. Remove the tiled parameter from your request that includes sld/sld_body. This is a requirement for Geoserver to attempt to leverage GWC's direct integration and seems to be the only thing that actually causes Geoserver to treat the request as a standard WMS request in these scenarios (reference). None of the other items in the GWC reference list have any impact on this condition.

If/when there is an update or change to this, I'll post it here and if anyone has a better answer/solution I'll be thrilled to delete/unmark this and accept it.

Other things we tried that did not fix the issue:

  • Creating a blank/dummy layer and providing it in the layers parameter
  • Geoserver Version - Confirmed this issue on Geoserver 2.9, 2.10, 2.11.1 and 2.12
  • Turning off caching for layers that we want to use sld/sld-body (e.g. un-checking "Create a tile layer")
  • Physically deleting the GWC layer configuration in the gwc-layers directory for the layer we want to use sld/sld_body and restarting
  • Different versions of WMS: 1.1.1/1.3.0
  • Just about every SLD syntax combo conceivable
  • Adding a parameter that is not included in the layers cache configuration parameter filters.
  • Requesting an image/tile with a width/height different than what's saved in the layers cache configuration (e.g. not 256x256)
  • Requesting an image/tile with an srs or crs not included in one of the available tile layer gridsets (e.g. not 900913 or 4326 by default)

The only thing that works is removing tiled or turning off Direct Integration.

Hopefully this will help someone else avoid some hair-tearing-out.

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.