Error 001369 when overwriting locator\geocode service

567
5
03-26-2021 03:52 AM
Tim_McGinnes
Occasional Contributor III

I have been able to successfully publish a locator to our portal. Works great in a web map and in ArcGIS Pro both in the locator pane and the batch geocoding tools. Used the Create Locator tool in ArcGIS Pro 2.7.2 and published to Enterprise 10.6.1.

I am now trying to update the locator with new addresses. I have successfully used the Rebuild Address Locator tool and tested it locally in Pro to see that the new addresses are being found. However I am getting ERROR 001369: Failed to create the service whenever I try to overwrite or update the locator and geocoding service. I have tried the Overwrite Locator tool in Pro and also this Updating Geocoding Services script. I have also now downgraded to ArcGIS Pro 2.6.3 and rebuilt the locator from scratch, but am still getting the same error when overwriting.

# Execute StageService to convert sddraft file to a service definition (sd) file
arcpy.server.StageService(sddraft_file, sd_file)
# Execute UploadServiceDefinition to publish the service definition file as a service
arcpy.server.UploadServiceDefinition(sd_file, ags_connection)
arcpy.AddMessage("The geocode service was successfully published")

It does the StageService fine but is erroring on the Upload Service Definition line. Here is the full error message from the script output:

An error occured ERROR 001369: Failed to create the service.
Failed to execute (Publish Service Definition).
Failed.
Failed to execute (Publish Service Definition).
Failed.
Failed to execute (UploadServiceDefinition).

ERROR 001369: Failed to create the service.
Failed to execute (Publish Service Definition).
Failed.
Failed to execute (Publish Service Definition).
Failed.
Failed to execute (UploadServiceDefinition).

Error thrown
Traceback (most recent call last):
  File "Update.py", line 235, in main
    arcpy.server.UploadServiceDefinition(sd_file, ags_connection)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py", line 1263, in UploadServiceDefinition
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py", line 1260, in UploadServiceDefinition
    retval = convertArcObjectToPythonObject(gp.UploadServiceDefinition_server(*gp_fixargs((in_sd_file, in_server, in_service_name, in_cluster, in_folder_type, in_folder, in_startupType, in_override, in_my_contents, in_public, in_organization, in_groups), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 511, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 001369: Failed to create the service.
Failed to execute (Publish Service Definition).
Failed.
Failed to execute (Publish Service Definition).
Failed.

Is anyone able to help with this? Thanks.

0 Kudos
5 Replies
JayantaPoddar
MVP Esteemed Contributor

Could you stop the existing Geocode Service, and then redo the proces?



Think Location
0 Kudos
Tim_McGinnes
Occasional Contributor III

@JayantaPoddar , I have narrowed down the error to ArcGIS Server being unable to rename the service. This occurred regardless if I manually stopped the service prior to doing the overwrite, or if ArcGIS Server automatically stopped the service during the overwrite. Here are some logs of both scenarios.

Creating the Locator service then overwriting it:

Overwrite Locator_YYY Service
VERBOSE Job 'j245c93962c164bd58f60ef87eaf56eda' for service 'System/PublishingToolsEx' completed its execution. The status of the job after completion was 'esriJobFailed'. Elapsed time '25644' ms. 2021-03-26T20:29:01 Server
SEVERE Error executing tool. PublishServiceDefinition Job ID: j245c93962c164bd58f60ef87eaf56eda : ERROR 001369: Failed to create the service. (more) 2021-03-26T20:29:01 System/PublishingToolsEx.GPServer
VERBOSE Execute job j245c93962c164bd58f60ef87eaf56eda 2021-03-26T20:29:01 System/PublishingToolsEx.GPServer
VERBOSE End execute 2021-03-26T20:29:01 System/PublishingToolsEx.GPServer
INFO Deleted the item 'i038f087b-77dd-4694-bb6a-68537ec31ae0' successfully. 2021-03-26T20:29:01 Admin
SEVERE Failed to create the service.: ERROR: code:500, Failed to rename service 'Locator_YYY.GeocodeServer'., Internal server error. 2021-03-26T20:29:01 System/PublishingToolsEx.GPServer
FINE End create service wrapper 2021-03-26T20:29:01 System/PublishingToolsEx.GPServer
VERBOSE Released 'service-locator_yyy_202103262028.geocodeserver' workflow lock. 2021-03-26T20:29:01 Admin
VERBOSE Released 'service-locator_yyy.geocodeserver' workflow lock. 2021-03-26T20:29:01 Admin
SEVERE Failed to rename service 'Locator_YYY.GeocodeServer'. 2021-03-26T20:29:01 Admin
FINE Shutting down an instance of service 'Locator_YYY.GeocodeServer'. 2021-03-26T20:28:36 Locator_YYY.GeocodeServer
FINE Shutting down an instance of service 'Locator_YYY.GeocodeServer'. 2021-03-26T20:28:36 Locator_YYY.GeocodeServer
VERBOSE Acquired 'service-locator_yyy.geocodeserver' workflow lock. 2021-03-26T20:28:36 Admin
VERBOSE Stopping the service 'Locator_YYY.GeocodeServer'. 2021-03-26T20:28:36 Admin
INFO Service to publish: [name: Locator_YYY; type: GeocodeServer]. 2021-03-26T20:28:36 System/PublishingToolsEx.GPServer
VERBOSE Job j245c93962c164bd58f60ef87eaf56eda is successfully submitted. 2021-03-26T20:28:35 System/PublishingToolsEx.GPServer

Create Locator_YYY
VERBOSE Job 'j09315681d0ba4a9abff4246a7955a24e' for service 'System/PublishingTools' completed its execution. The status of the job after completion was 'esriJobSucceeded'. Elapsed time '25076' ms. 2021-03-26T20:13:20 Server
INFO Service published [name: Locator_YYY; type: GeocodeServer]. 2021-03-26T20:13:17 System/PublishingToolsEx.GPServer
INFO Service 'Locator_YYY.GeocodeServer' was created successfully. 2021-03-26T20:13:10 Admin
INFO Service to publish: [name: Locator_YYY; type: GeocodeServer]. 2021-03-26T20:12:57 System/PublishingToolsEx.GPServer
VERBOSE Job j09315681d0ba4a9abff4246a7955a24e is successfully submitted. 2021-03-26T20:12:55 System/PublishingTools.GPServer

Creating the locator service, manually stopping the service, then overwriting it:

Overwrite Locator_AAA Service
VERBOSE Job 'jc09b7e8d949c41ef8750e7237f9d9d85' for service 'System/PublishingTools' completed its execution. The status of the job after completion was 'esriJobFailed'. Elapsed time '27614' ms. 2021-03-27T08:55:49 Server
SEVERE Error executing tool. PublishServiceDefinition Job ID: jc09b7e8d949c41ef8750e7237f9d9d85 : ERROR 001369: Failed to create the service. (more) 2021-03-27T08:55:49 System/PublishingTools.GPServer
SEVERE Error executing tool. PublishServiceDefinition Job ID: ja56785d59ca7429390142f914c288b7c : ERROR 001369: Failed to create the service. (more) 2021-03-27T08:55:47 System/PublishingToolsEx.GPServer
VERBOSE Execute job ja56785d59ca7429390142f914c288b7c 2021-03-27T08:55:47 System/PublishingToolsEx.GPServer
VERBOSE End execute 2021-03-27T08:55:47 System/PublishingToolsEx.GPServer
INFO Deleted the item 'i50bc29e8-722f-4bc6-b531-3201340105b1' successfully. 2021-03-27T08:55:47 Admin
SEVERE Failed to create the service.: ERROR: code:500, Failed to rename service 'Locator_AAA.GeocodeServer'., Internal server error. 2021-03-27T08:55:47 System/PublishingToolsEx.GPServer
FINE End create service wrapper 2021-03-27T08:55:47 System/PublishingToolsEx.GPServer
VERBOSE Released 'service-locator_aaa_202103270855.geocodeserver' workflow lock. 2021-03-27T08:55:47 Admin
VERBOSE Released 'service-locator_aaa.geocodeserver' workflow lock. 2021-03-27T08:55:47 Admin
SEVERE Failed to rename service 'Locator_AAA.GeocodeServer'. 2021-03-27T08:55:47 Admin
WARNING Unable to process request. Error handling service request :Could not find service. Service may be stopped or it may not be configured. 2021-03-27T08:55:40 Rest
INFO Service to publish: [name: Locator_AAA; type: GeocodeServer]. 2021-03-27T08:55:23 System/PublishingToolsEx.GPServer
VERBOSE Job jc09b7e8d949c41ef8750e7237f9d9d85 is successfully submitted. 2021-03-27T08:55:21 System/PublishingTools.GPServer

Stop Locator_AAA Service
VERBOSE Released 'service-locator_aaa.geocodeserver' workflow lock. 2021-03-27T08:51:47 Admin
VERBOSE Stopping the service 'Locator_AAA.GeocodeServer'. 2021-03-27T08:51:46 Admin
FINE Shutting down an instance of service 'Locator_AAA.GeocodeServer'. 2021-03-27T08:51:46 Locator_AAA.GeocodeServer
VERBOSE Acquired 'service-locator_aaa.geocodeserver' workflow lock. 2021-03-27T08:51:46 Admin

Create Locator_AAA
VERBOSE Job 'je99488525f97409f8d54f9b88cf63875' for service 'System/PublishingTools' completed its execution. The status of the job after completion was 'esriJobSucceeded'. Elapsed time '25411' ms. 2021-03-27T08:49:42 Server
INFO Service published [name: Locator_AAA; type: GeocodeServer]. 2021-03-27T08:49:40 System/PublishingToolsEx.GPServer
INFO Service 'Locator_AAA.GeocodeServer' was created successfully. 2021-03-27T08:49:32 Admin
INFO Service to publish: [name: Locator_AAA; type: GeocodeServer]. 2021-03-27T08:49:18 System/PublishingToolsEx.GPServer
VERBOSE Job je99488525f97409f8d54f9b88cf63875 is successfully submitted. 2021-03-27T08:49:16 System/PublishingTools.GPServer

 

0 Kudos
MichaelVolz
Esteemed Contributor

Are you planning to make this an automated solution?  If so, I would be interested to how you are able to automate the stopping of the geocode service as this is part of the current process that I have thus far been unable to migrate from a python 2.7 script (ArcMap) to python 3.6 script (Pro).

0 Kudos
Tim_McGinnes
Occasional Contributor III

@MichaelVolz I was planning to semi automate this - on demand at the moment. From looking at the logs, you shouldn't need to manually stop the service as the overwrite process handles it all. That Updating Geocoding Services script in my original post already works in Pro & Python 3.6.

Here's a great video with various options for updating locators and services where that script is discussed:

https://community.esri.com/t5/devsummit-conference-videos/updating-your-locator-service/m-p/976744 

0 Kudos
SarahBenner
New Contributor II

@MichaelVolz, this is something I've been working on lately; automating the rebuild and republishing of locator services since in our city, they need to be done on a weekly basis.  While I am still working out how to programmatically replace the service once it has been rebuilt, the code for rebuilding the locator and stopping the service via python is below:

import arcpy
from arcgis.gis import GIS
import arcgis.gis.admin 
import os

#create a new locator for a locator on disk
target_locator_name = 'Locator_Local'
local_locator_name = r'Locator_Local.loc'
local_locator_folder = r'C:\ArcGIS\Workspaces\Locators_ArcPro'
local_locator_path = os.path.join(local_locator_folder,local_locator_name)
locator = arcpy.geocoding.Locator(local_locator_path)

def print_profile_info(gis):
#prints connection information for the supplied gis
    print("Successfully logged into '{}' via the '{}' user".format(
           gis.properties.portalHostname,
           gis.properties.user.username)) 


def print_locator_info(locator):
# print out locator info
# all of these properties are only updatable via the updateLocator() method
# on a local copy of the service.  
# Update locally & publish again to update the service
    print('Categories: ' + locator.categories)
    # print(locator.capabilities) #only supported for geocoding services, not local locators
    print('Min match score: ' + str(locator.minMatchScore))
    print('Min candidate score: ' + str(locator.minCandidateScore))
    print('Max candidates: ' + str(locator.maxCandidates))
    print('Max suggest candidates: ' + str(locator.maxSuggestCandidates))
    print('Default suggest candidates: ' + str(locator.defaultSuggestCandidates))
    print('Match out of range: ' + str(locator.matchOutOfRange))
    print('Reverse geocode feature types: ' + str(locator.reverseGeocodeFeatureTypes))
    print('Supported countries: ' + str(locator.supportedCountries))
    print('Spatial reference: ' + str(locator.spatialReference))

    # these properties are read only
    print('Supported Roles: ' + locator.supportedRoles)
    # print('Single line input field: ' + str(locator.singleLineField.name))//in version 2.6 there is no such property


def rebuild_the_locator(locator_path):
#between software updates, rebuilding the locator is sufficient
#to ensure the locator is up to date with any changes made 
#to the base data from which it was created.
#this method takes in a locator to be rebuilt
#after rebuilding, call a method to overwrite the locator service
    arcpy.geocoding.RebuildAddressLocator(locator_path)
    print('Locator, {}, rebuild complete'.format(target_locator_name))


def update_the_locator(locator):
# Update the re-created locator with the original settings
    locator.categories = loc_categories
    locator.minMatchScore = loc_minMatchScore
    locator.minCandidateScore = loc_minCandidateScore
    locator.maxCandidates = loc_maxCandidates
    locator.maxSuggestCandidates = loc_maxSuggestCandidates
    locator.defaultSuggestCandidates = loc_defaultSuggestCandidates
    locator.matchOutOfRange = loc_matchOutOfRange
    locator.updateLocator()
    print('Locator, {}, updates complete'.format(target_locator_name))


#first, print the locator info for review/debugging
print_locator_info(locator)

#second, save the current locator settings to use after 
# the locator is re-created
loc_categories = locator.categories
loc_minMatchScore = locator.minMatchScore
loc_minCandidateScore = locator.minCandidateScore
loc_maxCandidates = locator.maxCandidates
loc_maxSuggestCandidates = locator.maxSuggestCandidates
loc_defaultSuggestCandidates = locator.defaultSuggestCandidates
loc_matchOutOfRange = locator.matchOutOfRange
print('Settings saved')

#third, rebuild or re-create the locator as needed
print('Rebuilding the locator')
rebuild_the_locator(local_locator_path)

#fourth, update the locator with the original settings in case these 
#changed during the rebuild
print('Updating the locator with the saved settings')
update_the_locator(locator)

#fifth, connect to the portal and stop the published locator service
#via locally saved profile that contains 
#username and password
portal_gis = GIS(profile="PORTAL_GIS")
print_profile_info(portal_gis)
portal_servers = portal_gis.admin.servers.list()
first_server = portal_servers[0]
print(first_server.url)
locators_list = first_server.services.list(folder='Locators')
print(locators_list)

for locator_item in locators_list:
    # print(locator_item.iteminformation.properties)
    print(locator_item.iteminformation.properties['name'])
    if locator_item.iteminformation.properties['name'] == target_locator_name:
        print(locator_item.status)
        locator_item.stop()
        print(locator_item.status)

#sixth, connect to the hosting server and overwrite the locator service

#seventh, restart the published locator service

print('All done.')

 

 

0 Kudos