0

I have a bunch of layers stored in Geoserver. However, when I try to preview certain layers, a WMS exception gets thrown.

<ServiceExceptionReport version="1.1.1" >
    <ServiceException code="NoDefaultStyle">
        Could not find a style for layer wyoming:GoatHuntAreas2014, either none was specified or no default style is available for it
    </ServiceException>
</ServiceExceptionReport>

When trying to manage the layer, I click on the "Publishing" tab and I see the following error message (truncated).

Any ideas? How can I go back and set a "default style?"

org.apache.wicket.WicketRuntimeException: Exception in rendering component: [MarkupContainer [Component id = defaultStyle]]
at org.apache.wicket.Component.renderComponent(Component.java:2725)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1538)
at org.apache.wicket.Component.render(Component.java:2517)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1440)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1603)
at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1527)
at org.apache.wicket.Component.renderComponent(Component.java:2686)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1538)
at org.apache.wicket.Component.render(Component.java:2517)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1440)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1603)

2 Answers 2

1

For anyone else who wants to know how to recover a layer when the default style is deleted and it breaks the entire layer and essentially the GeoServer GUI interface for that layer.

1) Create a new default style SLD file using the GeoServer GUI or through curl.

I ended up being able to create the new default style SLD file through the GUI. I called it GameUnits_Wyoming. If you can't do it through the GUI, try curl.

To do this with curl...

curl -u admin:password -XPOST -H 'Content-type: text/xml' -d '<style><name>GameUnits_Wyoming</name><filename>gameunits_wyoming.sld</filename></style>' http://localhost:8080/geoserver/rest/styles

curl -u admin:password -XPUT -H 'Content-type: application/vnd.ogc.sld+xml' -d @gameunits_wyoming.sld.sld http://localhost:8080/geoserver/rest/styles/GameUnits_Wyoming

2) Assign the new default style to the layer.

curl -u admin:password -XPUT -H 'Content-type: text/xml' -d '<layer><defaultStyle><name>GameUnits_Wyoming</name></defaultStyle></layer>' http://localhost:8080/geoserver/rest/layers/wyoming:GoatHuntAreas2014

Hopefully, someone else will find this useful.

0

It looks like you have deleted or renamed the style that was the default for those layers. The easiest way to fix this is to delete the layers affected and recreate them using your restore/load scripts.

Alternatively you can restore the whole data directory from your last backup.

If you don't have a backup or load scripts then look on this as learning opportunity and be more careful next time.

4
  • I would love to use it as a learning lesson if I could determine how it became corrupted. It worked and then it didn't. However, I didn't edit or delete any styles. Commented May 24, 2016 at 19:08
  • Also, I can't even delete the layer and start over. I get another error trying to just delete a layer. Any suggestion how to go about that? Commented May 24, 2016 at 19:10
  • Just restore from your backups then
    – Ian Turton
    Commented May 25, 2016 at 9:54
  • OK, I guess if that is the only viable solution... I was hoping to actually find the answer to the question why this has happened as I haven't changed any styles, how to stop it from happening again, and, at least, learn how to delete the offending layers. Commented May 25, 2016 at 13:49

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.