2

Here is the error in the GeoServer log (as it is returned to the caller):

 2019-10-28 17:03:59,021 INFO [geoserver.wfs] - 
 Request: getServiceInfo
 2019-10-28 17:03:59,053 ERROR [geoserver.ows] - 
 org.geoserver.wfs.WFSException: Could not locate {http://my.namespaceurl.com}MyLayerName in catalog.

Here is the code I used to register a new OpenLayers.Protocol.WFS control:

var theProtocol = new OpenLayers.Protocol.WFS({
    version: "1.1.0",
    url: "http://my.geoserver.sample:8080/geoserver/wfs",
    featurePrefix: "MyWorkspaceName",
    featureType: "MyLayerName",
    srsName: "EPSG:900913",
    featureNS: "http://my.namespaceurl.com", 
    geometryName: "the_geom"
});
var theFeatureControl = new OpenLayers.Control.GetFeature({
    protocol: theProtocol,
    maxFeatures: 2,
    clickTolerance: 10,
    box: false
});
theFeatureControl.events.register("featureselected", this, function (e) {
    ...
});
theFeatureControl.events.register("featureunselected", this, function (e) {
...
});
theMap.addControl(theFeatureControl);
theFeatureControl.activate();

And in GeoServer, I have a workspace named "MyWorkspaceName" with a namespace of "http://my.namespaceurl.com" and a layer named "MyLayerName" ...

This all worked with a GeoServer 2.8, now I've installed a new server with the lastest version (2.16 at this time) and created the same workspaces, stores, and layers. But this one function seems to be getting tripped up somehow, instead of finding "MyWorkspaceName:MyLayerName" it seems to be using the namespace name??

Anybody ever had a similar thing happen? Any hints/ideas?

1 Answer 1

2

Ok, there are two unrelated issues going on. The first, fixing the error described, was my mistake - the original namespace for the workspace on the older Geoserver was in fact "http://my.namespaceurl.com" and that is what we pass in the code above, but the namespace was actually entered on the new Geoserver without the "http://" and I did not notice that until now. So I fixed it. The error was correct, that namespace did NOT match any workspaces...

But when I fixed the namespace name for the workspace, the queries began "working", but not returning anything even though I knew they should.

This is legacy code, and I recall that we had to add the featureNS attribute to make it work with the older version of Geoserver, no idea why. I've now altered the code above to NOT include the featureNS at all, just the workspace name as the featurePrefix and the layer name as the featureType. Here is the new example:

var theProtocol = new OpenLayers.Protocol.WFS({
    version: "1.1.0",
    url: "http://my.geoserver.sample:8080/geoserver/wfs",
    featurePrefix: "MyWorkspaceName",
    featureType: "MyLayerName",
    srsName: "EPSG:900913",
    featureNS: ''  // removed this... "http://my.namespaceurl.com", 
    geometryName: "the_geom"
});

All is working great now. I can probably remove the featureNS attribute entirely now that I think of it.

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.