Problem with Geoprocessing Service

5189
10
04-07-2011 12:01 PM
Gregory_L___Greg_Gunther
New Contributor II
We have a geoprocessing service running in ArcGIS Server 10 sp1 java edition.  It is basically the same as the population summary/demographics GP Example.



The geoprocessing service runs fine in ArcMap and in ArcGIS Explorer as a service from ArcGIS Server.




When trying to implement the service within a web app using the javascript api based on this sample http://help.arcgis.com/en/webapi/javascript/arcgis/demos/gp/gp_zonalstats.html (and even with the flex sample) I keep getting "dojo.io.script.jsonp_dojoIoScript2._jsonpCallback({"error":{"code":500,"message":"Error executing task 'SumZone'. Please check your parameters.","details":[]}});"





We have tried everything
1.  Running it locally
2.  local jobs folder, etc
3.  Both on 9.3.1 and 10

Here is the REST request with the geometry payload to execute the service
http://igskaecgas010:8399/arcgis/rest/services/tmtools/ZonalStats/GPServer/SumZone/execute?f=json&en...{%22geometryType%22%3A%22esriGeometryPolygon%22%2C%22features%22%3A[{%22geometry%22%3A{%22rings%22%3A[[[-12089524.992070802%2C4855463.220549357]%2C[-12083410.029807992%2C4851488.49507853]%2C[-12084021.526034273%2C4851488.49507853]%2C[-12086773.259052537%2C4851488.49507853]%2C[-12089524.992070802%2C4849654.006399686]%2C[-12089524.992070802%2C4853017.2356442325]%2C[-12089524.992070802%2C4855463.220549357]]]%2C%22spatialReference%22%3A{%22wkid%22%3A102100}}}]%2C%22sr%22%3A{%22wkid%22%3A102100}}&callback=dojo.io.script.jsonp_dojoIoScript2._jsonpCallback

Here is the web app (but the map server is internal so you wont be able to see that).

A six pack to the one who can help me with this!
0 Kudos
10 Replies
HemingZhu
Occasional Contributor III
We have a geoprocessing service running in ArcGIS Server 10 sp1 java edition.  It is basically the same as the population summary/demographics GP Example.



The geoprocessing service runs fine in ArcMap and in ArcGIS Explorer as a service from ArcGIS Server.




When trying to implement the service within a web app using the javascript api based on this sample http://help.arcgis.com/en/webapi/javascript/arcgis/demos/gp/gp_zonalstats.html (and even with the flex sample) I keep getting "dojo.io.script.jsonp_dojoIoScript2._jsonpCallback({"error":{"code":500,"message":"Error executing task 'SumZone'. Please check your parameters.","details":[]}});"





We have tried everything
1.  Running it locally
2.  local jobs folder, etc
3.  Both on 9.3.1 and 10

Here is the REST request with the geometry payload to execute the service
http://igskaecgas010:8399/arcgis/rest/services/tmtools/ZonalStats/GPServer/SumZone/execute?f=json&env%3AoutSR=102100&env%3AprocessSR=102100&inputPoly={%22geometryType%22%3A%22esriGeometryPolygon%22%2C%22features%22%3A[{%22geometry%22%3A{%22rings%22%3A[[[-12089524.992070802%2C4855463.220549357]%2C[-12083410.029807992%2C4851488.49507853]%2C[-12084021.526034273%2C4851488.49507853]%2C[-12086773.259052537%2C4851488.49507853]%2C[-12089524.992070802%2C4849654.006399686]%2C[-12089524.992070802%2C4853017.2356442325]%2C[-12089524.992070802%2C4855463.220549357]]]%2C%22spatialReference%22%3A{%22wkid%22%3A102100}}}]%2C%22sr%22%3A{%22wkid%22%3A102100}}&callback=dojo.io.script.jsonp_dojoIoScript2._jsonpCallback

Here is the web app (but the map server is internal so you wont be able to see that).

A six pack to the one who can help me with this!


The most trickest part of running a GP on ArcGIS server using JS API is how to configure the parameters of the GP. If you use JSON expression to configure your parameters, you have to be perfect on writting them including the order etc. Here is the secret: if you are not sure how to write your Json (Java Script Object Notation) expression, use Java Object itself: Here is a code sample from my works, hope it help:

function clipLayer() {

    /* run the gp process to clip
    * and download TOPO and DEM layers
    * var ext = geometry.getExtent(); // for ArcGIS 9.3.1
    * constraint the extent to the minimum.
    * var strExtent = "" + ext.xmin + " " + ext.ymin + " " + ext.xmax + " " + ext.ymax;
    */
    var strExtent = "#";

    var graphic = new esri.Graphic();
    graphic.geometry = dataGraphic.geometry;

    /* parameter AOI */
    var clipFeature = [];
    clipFeature.push(graphic);
    var clipFeatureSet = new esri.tasks.FeatureSet();
    clipFeatureSet.features = clipFeature;

    /* parameter: featureformat or rasterformat */
    var featureformat = "";
    var rasterformat = "";
    if (lyrChoise == 1) featureformat = document.getElementById("Output_Format").value;
    else rasterformat = document.getElementById("Output_Format").value;

    /* using javascript new Object() to set up parameters
    * pros: the order does not have to match with service directory
    * and much easy to write code
    * multi line statements and might be slightly slow
    */
    var params = new Object();
    params.Feature_Format = featureformat;
    params.Raster_Format = rasterformat;
    params.Extent = strExtent;
    params.Layer_to_Clip = layer;
    params.Area_of_Interest = clipFeatureSet;


    /* or using Json expression to set up parameters
    * cons: the order has to match with service directory
    * compact (one line) and might be slightly fast
    */
    /* var params = { "Layer_to_Clip": layer, "Area_of_Interest": clipFeatureSet,
    "Feature_Format": featureformat, "Raster_Format": rasterformat, "Extent": strExtent }; */
    //document.getElementById("btnProcess").disabled = true;
    //processDisabled = true;
    gp.submitJob(params, completeCallback, statusCallback, gpFailed);
}
0 Kudos
Gregory_L___Greg_Gunther
New Contributor II
I am certain the json payload is being built ok because I have copied and used in on one of ESRI's samples and it works.  Here it is decoded:


{"geometryType":"esriGeometryPolygon","features": [{"geometry":{"rings":[[[-12035713.324158048,4906523.155443832],[-12006361.505296549,4886955.276202832],[-12035713.324158048,4877171.336582333],[-12035713.324158048,4906523.155443832]]],"spatialReference":{"wkid":102100}}}],"sr":{"wkid": 102100}}

Also, here is an error Im getting in the logs.  The grid does have a .vat so that isn't the problem.



<Msg time='2011-04-11T15:40:16' type='ERROR' code='20010' target='tmtools/zonal.GPServerSync' methodName='GPServerSync.CheckMessages' machine='IGSKAECGAS010' process='4936' thread='1504'>Executing (SumZone): ZonalStatsSum &quot;Feature Set&quot; in_memory\results Start Time: Mon Apr 11 15:40:16 2011 Executing (Zonal Statistics as Table): ZonalStatisticsAsTable &quot;Feature Set&quot; Id c:\arcgisserver\sumzone\grid.gdb\picall_wmb in_memory\results DATA SUM Start Time: Mon Apr 11 15:40:16 2011 ERROR 010160: Unable to open raster t_t3626\t_t3626. Zonal statistics program failed ERROR 010067: Error in executing grid expression. Failed to execute (Zonal Statistics as Table). Failed at Mon Apr 11 15:40:16 2011 (Elapsed Time: 0.00 seconds) Failed to execute (SumZone). Failed at Mon Apr 11 15:40:16 2011 (Elapsed Time: 0.00 seconds)</Msg>
<Msg time='2011-04-11T15:40:16' type='ERROR' code='20010' target='tmtools/zonal.GPServerSync' methodName='GPServerSync.CheckMessages' machine='IGSKAECGAS010' process='4936' thread='1504'>Error executing tool.: ERROR 010160: Unable to open raster t_t3626\t_t3626. Zonal statistics program failed ERROR 010067: Error in executing grid expression. Failed to execute (Zonal Statistics as Table). Failed to execute (SumZone).</Msg>
0 Kudos
HemingZhu
Occasional Contributor III
I am certain the json payload is being built ok because I have copied and used in on one of ESRI's samples and it works.  Here it is decoded:


{"geometryType":"esriGeometryPolygon","features": [{"geometry":{"rings":[[[-12035713.324158048,4906523.155443832],[-12006361.505296549,4886955.276202832],[-12035713.324158048,4877171.336582333],[-12035713.324158048,4906523.155443832]]],"spatialReference":{"wkid":102100}}}],"sr":{"wkid": 102100}}

Also, here is an error Im getting in the logs.  The grid does have a .vat so that isn't the problem.



<Msg time='2011-04-11T15:40:16' type='ERROR' code='20010' target='tmtools/zonal.GPServerSync' methodName='GPServerSync.CheckMessages' machine='IGSKAECGAS010' process='4936' thread='1504'>Executing (SumZone): ZonalStatsSum &quot;Feature Set&quot; in_memory\results Start Time: Mon Apr 11 15:40:16 2011 Executing (Zonal Statistics as Table): ZonalStatisticsAsTable &quot;Feature Set&quot; Id c:\arcgisserver\sumzone\grid.gdb\picall_wmb in_memory\results DATA SUM Start Time: Mon Apr 11 15:40:16 2011 ERROR 010160: Unable to open raster t_t3626\t_t3626. Zonal statistics program failed ERROR 010067: Error in executing grid expression. Failed to execute (Zonal Statistics as Table). Failed at Mon Apr 11 15:40:16 2011 (Elapsed Time: 0.00 seconds) Failed to execute (SumZone). Failed at Mon Apr 11 15:40:16 2011 (Elapsed Time: 0.00 seconds)</Msg>
<Msg time='2011-04-11T15:40:16' type='ERROR' code='20010' target='tmtools/zonal.GPServerSync' methodName='GPServerSync.CheckMessages' machine='IGSKAECGAS010' process='4936' thread='1504'>Error executing tool.: ERROR 010160: Unable to open raster t_t3626\t_t3626. Zonal statistics program failed ERROR 010067: Error in executing grid expression. Failed to execute (Zonal Statistics as Table). Failed to execute (SumZone).</Msg>


can you provide the gp part of you code?
0 Kudos
Gregory_L___Greg_Gunther
New Contributor II
function computeZonalStats(geometry) {
        /*After user draws shape on map using the draw toolbar compute the zonal*/
        map.showZoomSlider();
        map.graphics.clear();
       
        var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
        var graphic = new esri.Graphic(geometry,symbol);

        map.graphics.add(graphic);
        toolbar.deactivate();

        var features= [];
        features.push(graphic);

        var featureSet = new esri.tasks.FeatureSet();
        featureSet.features = features;
       
        var params = {};
  params.inputPoly = featureSet;
        gp.execute(params, displayResults, errorStatus);
      }
0 Kudos
HemingZhu
Occasional Contributor III
function computeZonalStats(geometry) {
        /*After user draws shape on map using the draw toolbar compute the zonal*/
        map.showZoomSlider();
        map.graphics.clear();
       
        var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
        var graphic = new esri.Graphic(geometry,symbol);

        map.graphics.add(graphic);
        toolbar.deactivate();

        var features= [];
        features.push(graphic);

        var featureSet = new esri.tasks.FeatureSet();
        featureSet.features = features;
       
        var params = {};
  params.inputPoly = featureSet;
        gp.execute(params, displayResults, errorStatus);
      }


I made a little change on your code (blow). I got "timeout exceeded" error. please check your PG settings. This thread might help: http://forums.arcgis.com/threads/15789-Long-running-gp-task-sort-of-fails.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>GP Task Population Zonal Stats</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.2/js/dojo/dijit/themes/claro/claro.css">
    <script type="text/javascript">djConfig = { parseOnLoad:true }</script>
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.2"></script>
    <script type="text/javascript">
      dojo.require("esri.map");
      dojo.require("esri.tasks.gp");
      dojo.require("esri.toolbars.draw");
      dojo.require("dijit.form.Button");
      dojo.require("dijit.Dialog");
      dojo.require("dojo.number");

      var map, gp, toolbar;

      /*Initialize map, GP & image params*/
      function init() {
        var initExtent = new esri.geometry.Extent({"xmin":-10726866.80142567,"ymin":3210110.331958949,"xmax":-8770078.877325676,"ymax":4667917.335413445,"spatialReference":{"wkid":102100}});
        map = new esri.Map("mapDiv",{extent:initExtent});
        dojo.connect(map, "onLoad", initTools);
   
        var streetMap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
        map.addLayer(streetMap);

        //var populationMap = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapSer...");
        //populationMap.setOpacity(0.5);
        //map.addLayer(populationMap);

        //identify proxy page to use if the toJson payload to the geoprocessing service is greater than 2000 characters.
        //If this null or not available the gp.execute operation will not work.  Otherwise it will do a http post to the proxy.
        //+++++++++++++ use your own
        esriConfig.defaults.io.proxyUrl = "proxy.ashx";
        esriConfig.defaults.io.alwaysUseProxy = false;
        //+++++++++++++++++++++++++++
      }

      function initTools(map) {
        gp = new esri.tasks.Geoprocessor("http://certmapper.cr.usgs.gov/arcgis/rest/services/tmtools/zonal/GPServer/SumZone");
        //gp.setOutSpatialReference({wkid:102100});
        //gp.setProcessSpatialReference({wkid:102100});
  //++++++++++++++++++++++
        dojo.connect(gp, "onExecuteComplete", displayResults);
        dojo.connect(gp, "onError", errorStatus);
        //++++++++++++++++++++++

        toolbar = new esri.toolbars.Draw(map);
        dojo.connect(toolbar, "onDrawEnd", computeZonalStats);
      }

      function computeZonalStats(geometry) {
        /*After user draws shape on map using the draw toolbar compute the zonal*/
        map.showZoomSlider();
        map.graphics.clear();
       
        //var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
        //var graphic = new esri.Graphic(geometry,symbol);
        var graphic = new esri.Graphic();
        graphic.geometry =geometry;


        map.graphics.add(graphic);
        toolbar.deactivate();

        var features= [];
        features.push(graphic);

        var featureSet = new esri.tasks.FeatureSet();
        featureSet.features = features;

        var params = {};
  params.inputPoly = featureSet;
        gp.execute(params);
      }
  
  //function statusCallback(jobInfo){
  // console.log(jobInfo.jobStatus);
  //}
  //++++++++++++++++++++++++
  function errorStatus(e){
   alert(e.message);
  }
        //++++++++++++++++++++++++

      function displayResults(result) {
        var content = dojo.string.substitute('<h1>The population in the user defined polygon is ${number:dojo.number.format}.</h1>',{number:results[0].value.features[0].attributes.SUM});

        dijit.byId('dialog1').setContent(content);
        dijit.byId('dialog1').show();
      }

      dojo.addOnLoad(init);
    </script>

  </head>
  <body class="claro">
    <table>
      <tbody>
        <tr>
          <td><div dojoType="dijit.form.Button" id="drawPoly" onclick="toolbar.activate(esri.toolbars.Draw.POLYGON);map.hideZoomSlider();">Summarize Population</div></td>
        </tr>
        <tr>
          <td id="mapDiv" style="width:800px; height:600px; border:1px solid #000;"></td>
        </tr>
      </tbody>
    </table>
    Click the Summarize Population tool and draw a polygon on the map.  When finished a GP task will be called to summarize the population within the polygon.
      <div dojoType="dijit.Dialog" id="dialog1" title="Population Summary"></div>
  </body>
</html>
0 Kudos
Gregory_L___Greg_Gunther
New Contributor II
Thanks for your help but I have been banging my head endlessly for a week now and have come to figure that it isn't client end stuff because both flex and jsapi don't work as well as just entering a json payload into the execute html form doesn't work as well.  Curious that it will work in ArcGIS Explorer and ArcMap but not from the REST API

This is the error when I try to invoke it via REST

Error executing tool.: ERROR 010160: Unable to open raster t_t966\t_t966. Zonal statistics program failed ERROR 010067: Error in executing grid expression. Failed to execute (Zonal Statistics as Table). Failed to execute (SumZone).  

ERROR   Executing (SumZone): ZonalStatsSum "Feature Set" in_memory\results Start Time: Wed Apr 13 11:32:31 2011 Executing (Zonal Statistics as Table): ZonalStatisticsAsTable "Feature Set" Id c:\arcgisserver\sumzone\picall_wmb in_memory\results DATA SUM Start Time: Wed Apr 13 11:32:31 2011 ERROR 010160: Unable to open raster t_t966\t_t966. Zonal statistics program failed ERROR 010067: Error in executing grid expression. Failed to execute (Zonal Statistics as Table). Failed at Wed Apr 13 11:32:31 2011 (Elapsed Time: 0.00 seconds) Failed to execute (SumZone). Failed at Wed Apr 13 11:32:31 2011 (Elapsed Time: 0.00 seconds)



So it seems to have something to do with the RASTER.  I have tried it in a geodatabase, as a filesystem raster and also have rebuilt the Raster attribute table.  I am stumped
0 Kudos
KevinHibma
Esri Regular Contributor
My comments are based entirely off the error message. It sounds like your JavaScript code is correct from everything you've done....

Start Time: Wed Apr 13 11:32:31 2011 ERROR 010160: Unable to open raster t_t966\t_t966. Zonal statistics program failed ERROR 010067: Error in executing grid expression. Failed to execute (Zonal Statistics as Table).


It looks like you have the data inside your c:\arcgisserver\ directories? If so, you can probably rule out ArcGISSOC account permission problems.
Next question is how are you referencing the data? It almost seems like you're referencing it as a raster layer - thus the tool is expecting an associated map service which holds the layer. Is this true? Or is the raster a "raster dataset", thus the raster parameter is pointing to something like c:\arcgisserver\rasterdata\t_t966 .... or something like that.
0 Kudos
Gregory_L___Greg_Gunther
New Contributor II
I think that is were the problem is, not on the web client end because I get the same error in flex, js, whatever.

Yes, the model is expecting a raster dataset which points to a raster that I have tried in both a geodatabase as well as just a file system raster.
0 Kudos
JimOakleaf
New Contributor
Did you ever get this figured out?
0 Kudos