Stuck on getting getResultImageLayer

3187
27
Jump to solution
10-24-2012 11:22 AM
SmaranHarihar
New Contributor III
I am getting back the success from the GP Tool but for some reason, when I execute the,

gp.getResultImageLayer(jobInfo.jobId,"final_shp", imageParams, function(gpLayer) {    map.addLayer(gpLayer);     });


I am receiving an error on the map.addLayer(gpLayer). The error is,

Network Error: 500 Internal Server Error - <complete path of the job directory where the final.shp is created>. What is causing the layer not to be added to the Map? This is the link.

This is my code,

<!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,IE=9" />         <!--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 Viewshed Task</title>         <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/dojo/dijit/themes/claro/claro.css">         <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css"         />         <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2compact"></script>         <script type="text/javascript">             dojo.require("esri.map");             dojo.require("esri.tasks.gp");             dojo.require("esri.layers.FeatureLayer");             dojo.require("esri.dijit.Popup");             dojo.require("dijit.TooltipDialog");              var map, gp, featureLayer, dialog;              /*Initialize map, GP*/             function init() {                 var startExtent = new esri.geometry.Extent({                     "xmin": -13644840.338547781,                     "ymin": 4529944.368315823,                     "xmax": -13614265.527233753,                     "ymax": 4552875.476801345,                     "spatialReference": {                         "wkid": 102100                     }                 });                  map = new esri.Map("mapDiv", {                     extent: startExtent                 });                 var streetMap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");                 map.addLayer(streetMap);                 //http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons (Drive Time Polygons)                 gp = new esri.tasks.Geoprocessor("http://webgis.arizona.edu/ArcGIS/rest/services/webGIS/Shock_Models/GPServer/Income_Log");                  gp.setOutputSpatialReference({                     wkid: 102100                 });                 dojo.connect(map, "onClick", computeViewShed);                 }              function computeViewShed(evt) {                 map.graphics.clear();                 if (map.graphicsLayerIds.length >= 1) {                     map.removeLayer(map.getLayer(map.graphicsLayerIds[0]));                 }                 var pointSymbol = new esri.symbol.SimpleMarkerSymbol();                 pointSymbol.setSize(20);                 pointSymbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0]), 1));                 pointSymbol.setColor(new dojo.Color([0, 0, 255, 0.25]));                  var graphic = new esri.Graphic(evt.mapPoint, pointSymbol);                 map.graphics.add(graphic);                  var features = [];                 features.push(graphic);                 var featureSet = new esri.tasks.FeatureSet();                 featureSet.features = features;                 var params = {                     "Input_Feature_Layer": featureSet,                     "Expression": "50"                 };                 //gp.execute(params, drawViewshed);                 gp.submitJob(params, completeCallback, statusCallback, function (error) {                     alert(error);                     //esri.hide(loading);                 });              }              function completeCallback(jobInfo) {                 if (jobInfo.jobStatus !== "esriJobFailed") {                     //gp.getResultData(jobInfo.jobId,"Output_Polygons", downloadFile);                     var imageParams = new esri.layers.ImageParameters();                     imageParams.imageSpatialReference = map.spatialReference;                     gp.getResultImageLayer(jobInfo.jobId, "final.shp", imageParams, function (gpLayer) {                         map.addLayer(gpLayer);                     });                 }             }               function statusCallback(jobInfo) {                 var status = jobInfo.jobStatus;                 if (status === "esriJobFailed") {                     alert(status);                     //esri.hide(loading);                 } else if (status === "esriJobSucceeded") {                     console.log("Success");                     //esri.hide(loading);                 }             }              dojo.addOnLoad(init);         </script>     </head>          <body class="claro">         <div id="mapDiv" style="width:800px; height:600px; border:1px solid #000;"></div>Click on map to execute my GP Task.</body>  </html>
0 Kudos
1 Solution

Accepted Solutions
nicogis
MVP Frequent Contributor
I see error:
Server Error - Object reference not set to an instance of an object when it's request image from mxd.

Have you set in gp service the Result Map Service of MapServer ?

Can you open request with support esri? it's difficult if I don't see model (settings, variable scratch ect.)

View solution in original post

0 Kudos
27 Replies
nicogis
MVP Frequent Contributor
if I see log with a sample request (via browser)

http://webgis.arizona.edu/ArcGIS/rest/services/webGIS/Shock_Models/GPServer/Income_Log/submitJob?Inp...

I see that output isn't in arcgisjobs but in your temp so it isn't accessible. Have you set variable stratchworkspace ? Name of Parameter output is final_shp (I see in code final.shp) and set it esriGPParameterTypeRequired.
0 Kudos
SmaranHarihar
New Contributor III
if I see log with a sample request (via browser)  

http://webgis.arizona.edu/ArcGIS/rest/services/webGIS/Shock_Models/GPServer/Income_Log/submitJob?Inp...

I see that output isn't in arcgisjobs but in your temp so it isn't accessible. Have you set variable stratchworkspace ? Name of Parameter output is final_shp (I see in code final.shp) and set it esriGPParameterTypeRequired.


Hi,

I apologize for the late response. Thank you for your reply. When I remotely log into the server and check for the jobs folder I am able to see the shapefile (final_shp) and it also has the results which I wish to display. The server wipes out all the job folders that were created at the end of the day. Here is the new job folder link and I am also able to see all the details of the output shapefile in this link as well.
I changed the final.shp to final_shp. My FLEX application uses the same GP Tool with the same settings and displays the output but I am not able to replicate it on Javascript.

Also this is the error that appears in the console,
  "NetworkError: 500 Internal Server Error - http://webgis.arizona.edu/ArcGIS/rest/services/webGIS/Shock_Models/GPServer/Income_Log/jobs/jc47c82f...
0 Kudos
nicogis
MVP Frequent Contributor
Have you details in log of rest, in event viewer windows and in iis?
0 Kudos
SmaranHarihar
New Contributor III
Have you details in log of rest, in event viewer windows and in iis?


Can you help me locate them? Not sure which are the files that I need to look into.
0 Kudos
SmaranHarihar
New Contributor III
Have you details in log of rest, in event viewer windows and in iis?


I tried it through fiddler and this was the output that I got for the 500 error,

SESSION STATE: Done.
Response Entity Size: 849 bytes.

== FLAGS ==================
BitFlags: [ClientPipeReused, ServerPipeReused] 0x18
X-CLIENTPORT: 2010
X-RESPONSEBODYTRANSFERLENGTH: 849
X-EGRESSPORT: 2023
X-HOSTIP: 128.196.53.161
X-PROCESSINFO: firefox:2248
X-CLIENTIP: 127.0.0.1
X-SERVERSOCKET: REUSE ServerPipe#2

== TIMING INFO ============
ClientConnected: 15:53:51.383
ClientBeginRequest: 15:53:51.494
GotRequestHeaders: 15:53:51.494
ClientDoneRequest: 15:53:51.494
Determine Gateway: 0ms
DNS Lookup:   0ms
TCP/IP Connect: 0ms
HTTPS Handshake: 0ms
ServerConnected: 15:52:45.077
FiddlerBeginRequest: 15:53:51.495
ServerGotRequest: 15:53:51.495
ServerBeginResponse: 15:53:51.679
GotResponseHeaders: 15:53:51.679
ServerDoneResponse: 15:53:51.679
ClientBeginResponse: 15:53:51.679
ClientDoneResponse: 15:53:51.679

 Overall Elapsed: 00:00:00.1850106

The response was buffered before delivery to the client.

== WININET CACHE INFO ============
This URL is not present in the WinINET cache. 
* Note: Data above shows WinINET's current cache state, not the state at the time of the request.
* Note: Data above shows WinINET's Medium Integrity (non-Protected Mode) cache only.
0 Kudos
nicogis
MVP Frequent Contributor
I see error:
Server Error - Object reference not set to an instance of an object when it's request image from mxd.

Have you set in gp service the Result Map Service of MapServer ?

Can you open request with support esri? it's difficult if I don't see model (settings, variable scratch ect.)
0 Kudos
SmaranHarihar
New Contributor III
Hey ciava,

Thank you so much for your help. Actually there was some problem with the Geoprocessing Tool and I was finally able to resolve it.

Here is my application. You can place one or more points and it works great. It will take around 20-25 sec.

Just one more question.

If I want to create popups for gplayer how can I do that?
0 Kudos
nicogis
MVP Frequent Contributor
Well I am happy for you!
If I have understand your question: see this sample http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_dialog.html
0 Kudos
SmaranHarihar
New Contributor III
Well I am happy for you!
If I have understand your question: see this sample http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_dialog.html


Thanks again for the reply ciava. I actually wanted to display the information that the 'gplayer' has, which I am receiving from the getResultImageLayer.

gp.getResultImageLayer(jobInfo.jobId,"final_shp", imageParams, function(gpLayer) {
   map.addLayer(gpLayer);
    });


So now that I have added the layer onto the map, I wish to fetch the content details of the gpLayer. There are four main fields that gpLayer has and I want to add it to the popup info.

Like in the example you gave, which displays the Lat and Long, I wish to use the same popup feature but instead of Lat and Long in contents, I want to display the data in the gpLayer.

I hope I was able to explain well.
0 Kudos