I have a geoprocessing service that was successfully published to our Server instance. I'm using 10.3 which means we could not publish unless it was successfully run as a tool in ArcMap. But now when I try calling the GP service form my client I am getting an error that the dataframe object was not created properly. I am not sure why the script works in ArcMap and not on the server. Here is the script
import sys, string, arcpy, os # get default script location scriptPath = sys.path[0] # Construct paths to mxd mxdFilePath = os.path.join(scriptPath,"Mymxd.mxd") mxd = arcpy.mapping.MapDocument(mxdFilePath) df = arcpy.mapping.ListDataFrames(mxd)[0] shpPath = arcpy.GetParameterAsText(0) newLayer = arcpy.mapping.Layer(shpPath) arcpy.mapping.AddLayer(df,newLayer,"TOP") arcpy.RefreshActiveView() del newLayer del mxdAnd here is the error
esriJobMessageTypeInformative: Submitted.esriJobMessageTypeInformative: Executing...esriJobMessageTypeInformative: Executing (MyService): MyService "Feature Set" C:\Users\~\AppData\Local\Temp\MyService\MyService_122215_1630_gpserver\j25ae6595a46840369acebfbd9d3fd12f\scratch\Printout1.pdfesriJobMessageTypeInformative: Start Time: Tue Dec 22 16:55:18 2015esriJobMessageTypeInformative: Executing (MyService): MyService "Feature Set" C:\Users\~\AppData\Local\Temp\MyService\MyService_122215_1630_gpserver\j25ae6595a46840369acebfbd9d3fd12f\scratch\Printout1.pdfesriJobMessageTypeInformative: Start Time: Tue Dec 22 16:55:18 2015esriJobMessageTypeInformative: Running script MyService...esriJobMessageTypeInformative: Success reading the mxd from \myserver\myshare\arcgisserver\directories\arcgissystem\arcgisinput\MyService\MyService_122215_1630.GPServer\extracted\v101\folder\MyService.mxdesriJobMessageTypeError: Traceback (most recent call last): File "\myserver\myshare\arcgisserver\directories\arcgissystem\arcgisinput\MyService\MyService_122215_1630.GPServer\extracted\v101\folder\GeoprocessingService_Test.py", line 20, in df = arcpy.mapping.ListDataFrames(mxd)[0] File "e:\arcgis\server\arcpy\arcpy\utils.py", line 181, in fn_ return fn(*args, **kw) File "e:\arcgis\server\arcpy\arcpy\mapping.py", line 1479, in ListDataFrames result = mixins.MapDocumentMixin(map_document).listDataFrames(wildcard) File "e:\arcgis\server\arcpy\arcpy\arcobjects\mixins.py", line 728, in listDataFrames return list(reversed(list(self.dataFrames))) File "e:\arcgis\server\arcpy\arcpy\arcobjects\mixins.py", line 695, in dataFrames return map(convertArcObjectToPythonObject, self.pageLayout.dataFrames) AttributeError: 'NoneType' object has no attribute 'dataFrames'esriJobMessageTypeError: Failed to execute (MyService).esriJobMessageTypeInformative: Failed at Tue Dec 22 16:55:19 2015 (Elapsed Time: 1.00 seconds)esriJobMessageTypeError: Failed to execute (MyService).esriJobMessageTypeInformative: Failed at Tue Dec 22 16:55:19 2015 (Elapsed Time: 1.00 seconds)esriJobMessageTypeError: Failed.
أكثر...
import sys, string, arcpy, os # get default script location scriptPath = sys.path[0] # Construct paths to mxd mxdFilePath = os.path.join(scriptPath,"Mymxd.mxd") mxd = arcpy.mapping.MapDocument(mxdFilePath) df = arcpy.mapping.ListDataFrames(mxd)[0] shpPath = arcpy.GetParameterAsText(0) newLayer = arcpy.mapping.Layer(shpPath) arcpy.mapping.AddLayer(df,newLayer,"TOP") arcpy.RefreshActiveView() del newLayer del mxdAnd here is the error
esriJobMessageTypeInformative: Submitted.esriJobMessageTypeInformative: Executing...esriJobMessageTypeInformative: Executing (MyService): MyService "Feature Set" C:\Users\~\AppData\Local\Temp\MyService\MyService_122215_1630_gpserver\j25ae6595a46840369acebfbd9d3fd12f\scratch\Printout1.pdfesriJobMessageTypeInformative: Start Time: Tue Dec 22 16:55:18 2015esriJobMessageTypeInformative: Executing (MyService): MyService "Feature Set" C:\Users\~\AppData\Local\Temp\MyService\MyService_122215_1630_gpserver\j25ae6595a46840369acebfbd9d3fd12f\scratch\Printout1.pdfesriJobMessageTypeInformative: Start Time: Tue Dec 22 16:55:18 2015esriJobMessageTypeInformative: Running script MyService...esriJobMessageTypeInformative: Success reading the mxd from \myserver\myshare\arcgisserver\directories\arcgissystem\arcgisinput\MyService\MyService_122215_1630.GPServer\extracted\v101\folder\MyService.mxdesriJobMessageTypeError: Traceback (most recent call last): File "\myserver\myshare\arcgisserver\directories\arcgissystem\arcgisinput\MyService\MyService_122215_1630.GPServer\extracted\v101\folder\GeoprocessingService_Test.py", line 20, in df = arcpy.mapping.ListDataFrames(mxd)[0] File "e:\arcgis\server\arcpy\arcpy\utils.py", line 181, in fn_ return fn(*args, **kw) File "e:\arcgis\server\arcpy\arcpy\mapping.py", line 1479, in ListDataFrames result = mixins.MapDocumentMixin(map_document).listDataFrames(wildcard) File "e:\arcgis\server\arcpy\arcpy\arcobjects\mixins.py", line 728, in listDataFrames return list(reversed(list(self.dataFrames))) File "e:\arcgis\server\arcpy\arcpy\arcobjects\mixins.py", line 695, in dataFrames return map(convertArcObjectToPythonObject, self.pageLayout.dataFrames) AttributeError: 'NoneType' object has no attribute 'dataFrames'esriJobMessageTypeError: Failed to execute (MyService).esriJobMessageTypeInformative: Failed at Tue Dec 22 16:55:19 2015 (Elapsed Time: 1.00 seconds)esriJobMessageTypeError: Failed to execute (MyService).esriJobMessageTypeInformative: Failed at Tue Dec 22 16:55:19 2015 (Elapsed Time: 1.00 seconds)esriJobMessageTypeError: Failed.
أكثر...