GeoProcessing service Issue accessing mxd using UNC Path

12-09-2016 06:10 AM
New Contributor

Hello! I'm having an issue with a GP service that runs a Python script. The script works fine in ArcGIS toolbox, but it fails when I run it as a GP Service. Is failing when tries to list the dataframes of the mxd in this line df = arcpy.mapping.ListDataFrames(mxd)[0]

part of the script that fails: 
TemplateMXD = r"\\kl-fs-003\GIS_Storage\Ancillary\Templates\Map_Document_Templates\Task_Based\Land_Registry_SketchUp_DrawingTemplate.mxd"
mxd = arcpy.mapping.MapDocument(TemplateMXD)
df = arcpy.mapping.ListDataFrames(mxd)[0]

The exception is: 

  • esriJobMessageTypeError: Traceback (most recent call last): File "D:\arcgissystem\arcgisinput\UK_I\ExportPropertySketchToShapefilePDF.GPServer\extracted\v101\afernandez\", line 170, in df = arcpy.mapping.ListDataFrames(mxd)[0] File "c:\program files\arcgis\server\arcpy\arcpy\", line 181, in fn_ return fn(*args, **kw) File "c:\program files\arcgis\server\arcpy\arcpy\", line 1479, in ListDataFrames result = mixins.MapDocumentMixin(map_document).listDataFrames(wildcard) File "c:\program files\arcgis\server\arcpy\arcpy\arcobjects\", line 728, in listDataFrames return list(reversed(list(self.dataFrames)))
  • File "c:\program files\arcgis\server\arcpy\arcpy\arcobjects\",
  • line 695, in dataFrames return map(convertArcObjectToPythonObject, self.pageLayout.dataFrames)
  • AttributeError: 'NoneType' object has no attribute 'dataFrames'

For some reason seems that the GP service is not able to open the mxd correctly. TemplateMXD is a UNC path and this path is Accessible to ArcGIS Server (in ArcGIS Server Manage, I've added  \\kl-fs-003\GIS_Storage\   as a Registered Folder) (see attached).   

The mxd is fine, and the layer that contains the mxd is correct, there is no problems or broken links in there.

Any ideas of what could be wrong ? 

0 Kudos
1 Reply
MVP Regular Contributor

The error line at the end states AttributeError: 'NoneType' object has no attribute 'dataFrames'.  Also when that part of the script is running the listDataFrames function looks like it requires a wildcard.  I would try to add a wildcard when listing the dataframes in the script e.g.

df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
0 Kudos