It seems like a GetLegendGraphic call doesn't use the OnlineResource configured in a style.
Sample steps to replicate it:
- put a legend.png in GEOSERVER_DATA_DIR/styles folder
- create a new "raster2" style copying it from the existing "raster" style and click on "addLegend"
- set legend.png on the Online Resource field and click on the "Auto-detect image size and type" link to automatically populate the other fields.
- Submit the style
- Create a new "raster" layer or simply modify an existing one
- Go to the publishing tab and scroll down to the "Default Style" drop down. Then select the raster2 style
The legend icon won't change to the static image and you still see the standard blue icon
Moreover after saving the layer config, a getLegendGraphic will still show the standard blue icon instead of the static image.
(even specifying an additional &style=raster2 parameter won't make any difference).
Some investigations have already been made on this: