[Geoserver-users] [Geoserver-devel] [JIRA] (GEOS-9756) Layer configured with missing style throws NPE

Moving this to the user list for discussion.
I tend to use grep in the data directory to search for the identifier when fixing this sort of issue by hand.

A lot of the code (rendering in this instance) needs to trust that the data structure is filled in correctly (in this case that a value is supplied).

The correct place to catch this is when the problem is introduced (reading an invalid configuration), rather than in all the many places that reference this data structure.

Q: Why would you rename pophatch.xml to pophatch.xml.break ?

jira-generated-image-static-comment-icon-e9033cfa-3467-42a4-b538-51dee8145d33.png

jira-generated-image-avatar-6e504e23-46c0-4085-9f66-69d181605c51.png

jira-generated-image-static-medium-68c1e55f-449f-43b1-8b8d-c5ebdaae2b95.png

···


Jody Garnett

Agreed, if someone breaks by hand the configuration it’s their problem to fix it, not something to be handled in the code.
If the link between layers and style has been broken without any manual intervention on the data directory, and without
any mis-update via the REST API, then we would very much like to know, and see if there is any way to reproduce,
so that the actual cause is isolated and fixed

Cheers
Andrea

···

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Q: Why would you rename pophatch.xml to pophatch.xml.break ?

This was the simplest step that I could take to reproduce the problem on a known default configuration.

How it happened in practice is that an entire workspace directory was copied from one GeoServer to another, but one of the style files that was referenced by a tiled layer (so the equivalent of pophatch.xml) was not copied across (possibly it was a global style).

The new instance started up without any warnings in the log file that [pophatch.xml] was missing.

When I browsed to Tile Caching > Tile Layers, the NPE was thrown, again without any indication of what the problem was or which layer was affected.

org.apache.wicket.WicketRuntimeException: Error attaching this container for rendering: [OddEvenItem [Component id = 8]]
at org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1848)

Caused by: java.lang.NullPointerException
at org.geoserver.gwc.layer.StyleParameterFilter.setLayer(StyleParameterFilter.java:197)

At the very least, I would like to add a log message when the catalog is loaded to warn of a missing style for a particular layer, which is why I wrote to the developer’s list, asking for guidance on how to fix it.

I agree with Jody that:

The correct place to catch this is when the problem is introduced (reading an invalid configuration), rather than in all the many places that reference this data structure.

so I propose to do this in gs-main/src/main/java/org/geoserver/config/GeoServerLoader.java around line 207.

Further, can I automatically remove a null/missing style, or is that dangerous/unacceptable?

Regards

Peter

On Thu, 1 Oct 2020 at 09:24, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Thu, Oct 1, 2020 at 9:01 AM Jody Garnett <jody.garnett@anonymised.com> wrote:

Q: Why would you rename pophatch.xml to pophatch.xml.break ?

Agreed, if someone breaks by hand the configuration it’s their problem to fix it, not something to be handled in the code.
If the link between layers and style has been broken without any manual intervention on the data directory, and without
any mis-update via the REST API, then we would very much like to know, and see if there is any way to reproduce,
so that the actual cause is isolated and fixed

Cheers
Andrea

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

so I propose to do this in gs-main/src/main/java/org/geoserver/config/GeoServerLoader.java around line 207.

Further, can I automatically remove a null/missing style, or is that dangerous/unacceptable?

I think it would be far smarter to issue a warning to allow folks to fix it by hand rather than lose their work.

Note we do have a workflow for configuration that fails to load, datastores that cannot connect are automatically disabled, perhaps you could take a similar approach to layers that are inconsistent because they are referencing a missing style.