question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot re-create layer after deletion

See original GitHub issue

I think this is rather a geoserver rest api bug, but i will start here…

i create a layer through the geoserver-manager and it works great (thx for the previous fix!)

next, when i delete the existing geoserver layer with

publisher.removeLayer(GEOSERVER_WORKSPACE, layerName);

the rest api log says:

07 Nov 15:04:27 INFO [org.geoserver.catalog.rest] - DELETE layer misu8:t1008

and returns 200 - OK (the store and layer name is good). the layer is not shown in the geoserver web interface.

but when i send in the same create call to re-create the same layer, i get an exception:

07 Nov 15:04:27 INFO [org.geoserver.catalog.rest] - DELETE layer misu8:t1008
07 Nov 15:04:27 INFO [org.geoserver] - Loaded feature type 't1008', enabled
07 Nov 15:04:27 DEBUG [org.geotools.jdbc] - CREATE CONNECTION
07 Nov 15:04:27 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION
07 Nov 15:04:27 ERROR [org.geoserver.rest] - :Resource named 't1008' already exists in store: 'misu8'
07 Nov 15:04:27 ERROR [org.geoserver.rest] -
org.geoserver.rest.RestletException: java.lang.IllegalArgumentException: Resource named 't1008' already exists in store: 'misu8'
        at org.geoserver.rest.ReflectiveResource.handleException(ReflectiveResource.java:325)
        at org.geoserver.rest.ReflectiveResource.handlePost(ReflectiveResource.java:123)
        at org.restlet.Finder.handle(Finder.java:296)
        at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:37)
        at org.restlet.Filter.doHandle(Filter.java:105)
        at org.restlet.Filter.handle(Filter.java:134)
        at org.restlet.Router.handle(Router.java:444)
        at org.geoserver.rest.RESTDispatcher$1.handle(RESTDispatcher.java:204)
        at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
        at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:86)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:23)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:74)
        at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:45)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:49)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
        at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
        at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
        at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
        at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
        at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:53)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
        at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:201)
        at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
        at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
        at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:82)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:68)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
        at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:72)
        at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
        at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:97)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:71)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:46)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalArgumentException: Resource named 't1008' already exists in store: 'misu8'
        at org.geoserver.catalog.impl.CatalogImpl.validate(CatalogImpl.java:381)
        at org.geoserver.catalog.impl.CatalogImpl.add(CatalogImpl.java:357)
        at org.geoserver.security.SecureCatalogImpl.add(SecureCatalogImpl.java:1006)
        at org.geoserver.catalog.impl.AbstractCatalogDecorator.add(AbstractCatalogDecorator.java:199)
        at org.geoserver.catalog.rest.FeatureTypeResource.handleObjectPost(FeatureTypeResource.java:182)
        at org.geoserver.rest.ReflectiveResource.handlePost(ReflectiveResource.java:120)
        ... 85 more

what am i doing wrong, should i delete something else to wipe out the layer definition?

thx

the configuration: geoserver-manager : geosolutions-it-geoserver-manager-v1.4.2-22-gfc4251f.zip (the branch with the fix for https://github.com/geosolutions-it/geoserver-manager/issues/45) geoserver: 2.2 (had to upgrade it since the last bug)

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
eblondelcommented, Oct 15, 2015

You should not use

publisher.removeLayer(GEOSERVER_WORKSPACE, layerName);

In geoserver, they are 2 different resources associated to a GIS web-layer, but the name of methods can lead to a misunderstanding. The different resources are:

  • the layer
  • the featureType

When you do you publishDBLayer, you publish both. When you do removeLayer you just remove the layer resource, not the featureType.

So to answer to your questions is there a way to completely remove a layer from the geoserver?

Yes, there is, using unpublishFeatureType instead of removeLayer. Again, the first unpublishes everything, the latter remove only layer part (that’s why you get an error)

1reaction
juvscommented, Oct 15, 2015

Old comment, but I found the possible solution…

Just call publisher.reload(), after your delete the layer to regenerate the geoserver catalog…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to delete or purge a layer in AutoCAD
A layer cannot be deleted in Layer Manager or purged using the PURGE command.
Read more >
Can't delete a selected layer using the 'delete' key CS6 [2013]
After googling for the same exact problem, I figured out the solution on my own. I just saved the .psd file as is,...
Read more >
deleted lambda layer version in aws console, not cannot run ...
using 4.25.0, reproducible by creating a lambda layer, adding it to a project, then deleting a version from the console.
Read more >
AWS: Delete lambda layer still retains layer version history
From what I read if no layer version exists and no reference exists, the version history should be gone, but I don't see...
Read more >
The selected layer was not deleted in autocad - YouTube
In this video, I explain to you how to Solve the error of “The selected layer was not deleted ” in AutoCAD.Issue:When trying...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found