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 am trying to learn how to use the OpenGeo suite by following the tutorials on the site. The one I'm currently trying to follow is http://workshops.opengeo.org/geoext/stores/capabilities.html. Most of it works, but I can't get the grid to populate with the layers from GeoServer. This is my code:

<html>
    <head>
        <title>GeoExt Workshop Application</title>
        <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css">
        <script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="ext/ext-all.js"></script>
        <script src="openlayers/lib/OpenLayers.js"></script>
        <script type="text/javascript" src="geoext/lib/GeoExt.js"></script>

        <script type="text/javascript">

        Ext.BLANK_IMAGE_URL = "ext/resources/images/default/s.gif";
        var app, items = [], controls = [];

        Ext.onReady(function() {
            app = new Ext.Viewport({
                layout: "border",
                items: items
            });
        });

        items.push({
            xtype: "gx_mappanel",
            ref: "mapPanel",
            region: "center",
            map: {
                numZoomLevels: 19,
                controls: controls
            },
            extent: OpenLayers.Bounds.fromArray([
                -122.911, 42.291,
                -122.787,42.398
            ]),
            layers: [new OpenLayers.Layer.WMS(
                "Medford",
                "http://localhost:8080/geoserver/wms",
                {layers: "medford"},
                {isBaseLayer: false}
            )]
        });
        controls.push(
            new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.Attribution(),
            new OpenLayers.Control.PanPanel(),
            new OpenLayers.Control.ZoomPanel()
        );

        items.push({
            xtype: "grid",
            ref: "capsGrid", // makes the grid available as app.capsGrid
            title: "Available Layers",
            region: "north",
            height: 150,
            viewConfig: {forceFit: true},
            store: new GeoExt.data.WMSCapabilitiesStore({
                url: "http://localhost:8080/geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1&",
                autoLoad: true
            }),
            columns: [
                {header: "Name", dataIndex: "name", sortable: true},
                {header: "Title", dataIndex: "title", sortable: true},
                {header: "Abstract", dataIndex: "abstract"}
            ],

            bbar: [{
                text: "Add to Map",
                handler: function() {
                    app.capsGrid.getSelectionModel().each(function(record) {
                        var clone = record.clone();
                        clone.getLayer().mergeNewParams({
                            format: "image/png",
                            transparent: true
                        });
                        app.mapPanel.layers.add(clone);
                        app.mapPanel.map.zoomToExtent(
                            OpenLayers.Bounds.fromArray(clone.get("llbbox"))
                        );
                    });
                }
            }]
        });

        </script>
    </head>
    <body>
    </body>
</html>

I've been playing around on firebug to try to figure out what's going on, particularly on the request

http://localhost:8080/geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1&

since this is the request that is supposed to get the layer info. The request header it sends is below. The response for some reason is 0 bytes. I'm not very familiar with web development, but I thought this should be a GET request instead of an OPTIONS request.

OPTIONS /geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1& HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Origin: null
Access-Control-Request-Method: GET
Access-Control-Request-Headers: x-requested-with
Connection: keep-alive

Here is the response header:

HTTP/1.1 200 OK
Allow: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS
Content-Length: 0
Server: Jetty(6.1.8)

What is going wrong? And how can I fix it?

EDIT: Here is part of the log file, which includes starting up OpenGeo and then loading the webpage I built in the tutorial. The rest is just the requests for the map tiles that look like

127.0.0.1 -  -  [23/Jan/2013:18:10:52 +0000] "GET /geoserver/wms?LAYERS=medford&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=-122.87109375,42.36328125,-122.8271484375,42.4072265625&WIDTH=256&HEIGHT=256 HTTP/1.1" 200 6993

I went over the character limit by including them so I took them out.

127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "HEAD /dashboard/version.ini HTTP/1.1" 200 0 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces.json HTTP/1.1" 200 685 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/AENVTest/datastores.json HTTP/1.1" 200 155 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/AENVTest/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/medford/datastores.json HTTP/1.1" 200 262 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/medford/coveragestores.json HTTP/1.1" 200 178 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/earth/datastores.json HTTP/1.1" 200 268 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/earth/coveragestores.json HTTP/1.1" 200 166 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/opengeo/datastores.json HTTP/1.1" 200 146 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/opengeo/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/usa/datastores.json HTTP/1.1" 200 148 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/usa/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:43 +0000] "GET /geoserver/rest/workspaces/analytics/datastores.json HTTP/1.1" 200 138 
127.0.0.1 -  -  [23/Jan/2013:18:10:44 +0000] "GET /geoserver/rest/workspaces/analytics/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:44 +0000] "GET /geoserver/rest/workspaces/world/datastores.json HTTP/1.1" 200 252 
127.0.0.1 -  -  [23/Jan/2013:18:10:44 +0000] "GET /geoserver/rest/workspaces/world/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:44 +0000] "GET /geoserver/rest/layers.json HTTP/1.1" 200 3036 
127.0.0.1 -  -  [23/Jan/2013:18:10:44 +0000] "GET /geoexplorer/maps/ HTTP/1.1" 200 556 
127.0.0.1 -  -  [23/Jan/2013:18:10:45 +0000] "HEAD /dashboard/version.ini HTTP/1.1" 200 0 
127.0.0.1 -  -  [23/Jan/2013:18:10:48 +0000] "HEAD /dashboard/version.ini HTTP/1.1" 200 0 
127.0.0.1 -  -  [23/Jan/2013:18:10:50 +0000] "HEAD /dashboard/version.ini HTTP/1.1" 200 0 
127.0.0.1 -  -  [23/Jan/2013:18:10:52 +0000] "OPTIONS /geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1 HTTP/1.1" 200 0 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "HEAD /dashboard/version.ini HTTP/1.1" 200 0 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces.json HTTP/1.1" 200 685 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/AENVTest/datastores.json HTTP/1.1" 200 155 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/AENVTest/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/medford/datastores.json HTTP/1.1" 200 262 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/medford/coveragestores.json HTTP/1.1" 200 178 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/earth/datastores.json HTTP/1.1" 200 268 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/earth/coveragestores.json HTTP/1.1" 200 166 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/opengeo/datastores.json HTTP/1.1" 200 146 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/opengeo/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/usa/datastores.json HTTP/1.1" 200 148 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/usa/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/analytics/datastores.json HTTP/1.1" 200 138 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/analytics/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/world/datastores.json HTTP/1.1" 200 252 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/workspaces/world/coveragestores.json HTTP/1.1" 200 21 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoserver/rest/layers.json HTTP/1.1" 200 3036 
127.0.0.1 -  -  [23/Jan/2013:18:10:53 +0000] "GET /geoexplorer/maps/ HTTP/1.1" 200 556 
127.0.0.1 -  -  [23/Jan/2013:18:10:55 +0000] "HEAD /dashboard/version.ini HTTP/1.1" 200 0 
share|improve this question
    
what is in the log file –  iant Jan 22 '13 at 20:54
    
When I open the web page, nothing is added to the log on the OpenGeo Dashboard. Do you mean that log, or is it something else? –  NinjaMeTimbers Jan 22 '13 at 22:05
    
look in the logs folder of your jetty install –  iant Jan 23 '13 at 8:15
1  
I suspect that means that you haven't started Jetty up, as I'm pretty sure it always logs something on start up. –  iant Jan 23 '13 at 15:47
1  
Looks like the server is not responding. Copy/paste localhost:8080/geoserver/… into address bar in browser and see if you can get a response. –  neogeomat Aug 22 '13 at 2:52
show 3 more comments

1 Answer 1

Read up on the Same Origin Policy. If your OpenLayers script is not on http://localhost:8080/ and your browser or server does not support CORS, that is your problem.

share|improve this answer
    
My code is in a html file called map.html, which I simply double click to open, so unless it's running on port 80, I'm not sure where its running. Firebug says the domain of the option request is localhost:8080 and gives the remote IP as 127.0.0.1:8080. I'm also assuming I need to set up a proxy, but I am unsure how to do this. –  NinjaMeTimbers Jan 23 '13 at 19:17
    
You could open your application through Jetty (from localhost:8080), then you won't need proxy. Sorry, haven't done this myself, and can't give any instructions. –  user1702401 Jan 23 '13 at 21:55
    
Don't double click the file - type the address of the web page with your map in it into your browser. It should start localhost:8080/geoserver... –  iant Jan 24 '13 at 8:23
    
Where should I be storing the file for this to work? –  NinjaMeTimbers Jan 28 '13 at 15:39
add comment

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.