'geoserver.log: Could not lookup context gwc as a workspace, trying as group

I've using Geoserver 2.20 downloaded from official site, I have configured gwc cache system and enabled layer for cache and global services over OGC Services on global settings.

When I try this URL I get this:

$ curl 'http://myserver/geoserver/geoserver/gwc/service/wms?SERVICE=WMS&REQUEST=GetMap&BBOX=-180,-90,0,80.33032694475760138&SRS=EPSG:4326&WIDTH=846&HEIGHT=800&LAYERS=ws:mylayer&FORMAT=image/png'

<html>
<head>
<title>GWC Error</title>
<link rel="stylesheet" href="../rest/web/gwc.css" type="text/css"/>
</head>
<body>
<div id="pageHeader"><a id="logo" href="../"><img src="../rest/web/geowebcache_logo.png"/></a></div>
<h4>400: class org.geowebcache.mime.ApplicationMime cannot be cast to class org.geowebcache.mime.ImageMime (org.geowebcache.mime.ApplicationMime and org.geowebcache.mime.ImageMime are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3524ee20)</h4></body></html>

Looking in geoserver.log for this request, I get:

2022-04-27 11:47:04,484 DEBUG [security.IncludeQueryStringAntPathRequestMatcher] - Request matched by universal pattern '/**'
2022-04-27 11:47:04,484 DEBUG [security.IncludeQueryStringAntPathRequestMatcher] - Matched Path: /gwc/service/wms, QueryString: SERVICE=WMS&REQUEST=GetMap&BBOX=-180,-90,0,80.33032694475760138&SRS=EPSG:4326&WIDTH=846&HEIGHT=800&LAYERS=ws:mylayer&FORMAT=image/png with /**
2022-04-27 11:47:04,485 TRACE [ows.OWSHandlerMapping] - Mapped to HandlerExecutionChain with [org.geoserver.ows.Dispatcher@318ec7d2] and 1 interceptors
2022-04-27 11:47:04,486 DEBUG [geoserver.ows] - Could not lookup context gwc as a workspace, trying as group
2022-04-27 11:47:04,486 DEBUG [geoserver.ows] - Could not lookup context gwc as a layer group either
2022-04-27 11:47:04,486 DEBUG [wms.WMSService] - Recombinining tiles to respond to WMS request
2022-04-27 11:47:04,487 ERROR [geowebcache.GeoWebCacheDispatcher] - class org.geowebcache.mime.ApplicationMime cannot be cast to class org.geowebcache.mime.ImageMime (org.geowebcache.mime.ApplicationMime and org.geowebcache.mime.ImageMime are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3524ee20) http://myserver/geoserver/gwc/service/wms
2022-04-27 11:47:04,487 DEBUG [util.ResponseUtils] - class org.geowebcache.mime.ApplicationMime cannot be cast to class org.geowebcache.mime.ImageMime (org.geowebcache.mime.ApplicationMime and org.geowebcache.mime.ImageMime are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3524ee20)
2022-04-27 11:47:04,487 ERROR [geowebcache.GeoWebCacheDispatcher] - Request failed
java.lang.ClassCastException: class org.geowebcache.mime.ApplicationMime cannot be cast to class org.geowebcache.mime.ImageMime (org.geowebcache.mime.ApplicationMime and org.geowebcache.mime.ImageMime are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3524ee20)
    at org.geowebcache.service.wms.WMSTileFuser.<init>(WMSTileFuser.java:325)
    at org.geowebcache.service.wms.WMSService.getFuser(WMSService.java:356)
...

I've try with this other URL http://myserver/geoserver/geoserver/ws/gwc/service/wms?SERVICE=WMS&REQUEST=GetMap&BBOX=-180,-90,0,80.33032694475760138&SRS=EPSG:4326&WIDTH=846&HEIGHT=800&LAYERS=ws:mylayer&FORMAT=image/png and don't runs too.

But this other URL for same sever and layer (with) runs ok: http://mysever/geoserver/gwc/demo/ws:mylayer?gridSet=EPSG:4326&format=image/png.

I've looked for this related question (Geoserver:No such workspace 'gwc/service') but do not solve my problem.

How can I solve it?

Regards.



Solution 1:[1]

The problem is the URL. It is incorrect.

Correct URL must refer to wmts service and not wms.

So it should be (for this example):

http://myserver/geoserver/geoserver/gwc/service/wmts?SERVICE=WMS&REQUEST=GetMap&BBOX=-180,-90,0,80.33032694475760138&SRS=EPSG:4326&WIDTH=846&HEIGHT=800&LAYERS=ws:mylayer&FORMAT=image/png

Available layers:

http://myserver/geoserver/geoserver/gwc/service/wmts?

Regards.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lodopidolo