Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm developing a GIS app that makes use of GeoServer and GeoWebCache for serving requests, and OpenLayers for frontend. WMS requests to the GeoServer are served with no issues. But when I make a request through GeoWebCache, nothing is returned to the client. I've enabled Direct WMS Integration in GeoWebCache configuration. I'm using GeoWebCache integrated in GeoServer. My request is as shown below:

var wmslayer = new OpenLayers.Layer.WMS(
   "Kenya Administrative Boundaries",
   "http://localhost:8081/geoserver/gwc/service/wms?", 
   {layers: 'kenya_admin', format:'image/png', transparent: true},
   {opacity: 1.0, isBaseLayer: false, visibility: true}
);
map.addLayer(wmsLayer);

But the layer is not loaded. Any advice on what I may be doing wrong. Thanks in advance.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

i want to say some solutions come to my mind.

1.check out GeoWebCache endpoint URL as http://example.com/geoserver/gwc/service/wms for GeoWebCache WMS instead.

2.check out your geowebcache.xml and openlayers whether same projection or not.

3.check out GeoWebCache demo page from http://localhost:8080/geoserver/gwc/demo.

4.check out your GeoWebCache Configuration, you can look an GWC Example here.

5.check out your param-value from cached tiles directory in web.xml(in web-inf dir) <param-value>C:\temp</param-value>

6.try to add tilesize and tileorigin to your wms option as

{ tileSize: new OpenLayers.Size(256,256),
  tileOrigin: new OpenLayers.LonLat(-180.0, 90.0)});

These are some issues about gwc which i want you to check out that has come to my mind for now.

i hope it helps you...

share|improve this answer
    
Thanks for the advice, Aragon. My GeoWebCache endpoint is correct; http://localhost:8082/geoserver/gwc/service/wms. The demos are also working fine. I'm going to confirm the projection, and tilesize, as I assumed that there must be default values for these. But I guess I have to explicitly specify them. –  okello May 23 '12 at 11:28

The easiest way to check what's going on is to look at what the server is saying in the log files or to check the response from the server using FireBug in firefox.

The most likely problems are projections and extents not lining up with what GWC is expecting.

share|improve this answer
    
I'm using FireBug. Its not showing any errors. From your suggestion, I guess I need to check Tomcat logs. I'll post my findings here. –  okello May 23 '12 at 11:24
    
is it showing any images? –  iant May 23 '12 at 15:58
    
No, Iant. Its not showing any images from GeoWebCache, only the OpenStreetMap map that I'd used as my base map. –  okello May 23 '12 at 18:36

Just for the record... I bumped into this same problem, and I figured that the problem was that I had to include the geoserver namespace in the layer name when referring it in the Openlayers code. So it should look like this:

var wmslayer = new OpenLayers.Layer.WMS(
   "Kenya Administrative Boundaries",
   "http://localhost:8081/geoserver/gwc/service/wms?", 
   {layers: 'namespace:kenya_admin', format:'image/png', transparent: true},
   {opacity: 1.0, isBaseLayer: false, visibility: true}
);
map.addLayer(wmsLayer);

Or you can even refer to the standard wms endpoint if you've previously enabled direct integration in GeoServer:

var wmslayer = new OpenLayers.Layer.WMS(
   "Kenya Administrative Boundaries",
   "http://localhost:8081/geoserver/wms?", 
   {layers: 'namespace:kenya_admin', format:'image/png', transparent: true},
   {opacity: 1.0, isBaseLayer: false, visibility: true}
);
map.addLayer(wmsLayer);

I hope it may help somebody in the future!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.