1

im able to create a data store in geoserver but when i try to access it in the geoserver admin console i get this error :

can't load chosen data, verify that the loader module is installed (sorry for this horrible traduction because the error message is in french)

enter image description here

and this is the code :

   public function createGeoTiffDataStore($datastoreName, $workspaceName, $location) {
    $data = '<dataStore>
                  <name>'.htmlentities($datastoreName, ENT_COMPAT).'</name>
                  <type>GeoTIFF</type>
                  <enabled>true</enabled>
                  <connectionParameters>
                    <entry key="url">file:'.htmlentities($location, ENT_COMPAT).'</entry>
                    <entry key="namespace">'.htmlentities($workspaceName, ENT_COMPAT).'</entry>
                  </connectionParameters>
            </dataStore>';
    return $this->runApi('workspaces/' . urlencode($workspaceName). '/datastores', 'POST', $data);
}


private function runApi($apiPath, $method = 'GET', $data = '', $contentType = 'text/xml') {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $this->serverUrl.'rest/'.$apiPath);
    curl_setopt($ch, CURLOPT_USERPWD, $this->username.":".$this->password);
    if ($method == 'POST') {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    } else if ($method == 'DELETE' || $method == 'PUT') {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    }

    if ($data != '') {
        curl_setopt($ch, CURLOPT_HTTPHEADER,
            array("Content-Type: $contentType",
                'Content-Length: '.strlen($data))
        );
    }

    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $rslt = curl_exec($ch);
    $info = curl_getinfo($ch);

    if ($info['http_code'] == 401) {
        return 'Access denied. Check login credentials.';
    } else {
        return $rslt;
    }
}
  • 1
    Did you try to load the GeoTiff with the UI instead of the REST API to check if issue is from your code or from the GeoServer install? – ThomasG77 Nov 9 '14 at 20:07
  • I will try thx il give a feedback as soon as pssible – noobdev Nov 9 '14 at 20:56
  • ok manual geotiff datastore its ok, i dont know if the problem come from my xml structure that geoserver can't understand – noobdev Nov 9 '14 at 21:53
0

ok i guess i found the problem :

1) i change my xml to this :

<coverageStore>
              <name>'.htmlentities($datastoreName, ENT_COMPAT).'</name>
              <type>GeoTIFF</type>
              <enabled>true</enabled>
              <connectionParameters>
              <entry key="url">file:'.htmlentities($location, ENT_COMPAT).'</entry>
              <entry key="namespace">'.htmlentities($workspaceName, ENT_COMPAT).'</entry>
              </connectionParameters>
        </coverageStore>

2) i change my url to target de coverageStore like this :

return $this->runApi('workspaces/' . urlencode($workspaceName). '/coveragestores', 'POST', $data);

so the problem was that im using the wrong xml schema and im targeting the wrong api correct me if im wrong

best regards.

  • Could you mark your own answer as correct, by clicking the green check mark? – mr.adam Jun 20 '17 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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