Select to view content in your preferred language

Publishing Webtool: "Fails to create the map service definition during staging"

628
4
Jump to solution
02-19-2026 04:06 PM
AlfredBaldenweck
MVP Frequent Contributor

I'm trying to publish a webtool to a federated server in Enterprise. It keeps failing with "Failed to create the map service definition during staging". However, it Analyzes with no errors or warnings. (It also fails if put on the Hosting server).

LAFI_Tools 35 WebTool GBP Wyoming Portal 2026-02-19 16:48:47 Status: InProgress StatusMessage: Consolidate data
LAFI_Tools 35 WebTool GBP Wyoming Portal  2026-02-19 16:48:49 Status: InProgress StatusMessage: Staging GP service
LAFI_Tools 35 WebTool GBP Wyoming Portal 2026-02-19 16:49:29 Status: Failed ErrorMessage: Consolidation failed
LAFI_Tools 35 WebTool GBP Wyoming Portal  2026-02-19 16:49:31 Status: InProgress StatusMessage: Failed to create the map service definition during staging.
LAFI_Tools 35 WebTool GBP Wyoming Portal  2026-02-19 16:49:31 Status: Failed ErrorMessage: ERROR 004017: Failed to create the map service definition during staging.
LAFI_Tools 35 WebTool GBP Wyoming Portal  2026-02-19 16:49:31 Status: Failed ErrorMessage: Failed to execute (StageService).
LAFI_Tools 35 WebTool GBP Wyoming Portal  2026-02-19 16:49:33 Status: Failed ErrorMessage: Staging failed

Here's the thing: I'm not asking for a map service?? Why is it trying to make one?

I have "URL Data: Convert feature layer" unchecked

AlfredBaldenweck_1-1771545382230.png

AlfredBaldenweck_0-1771545369587.png

I've narrowed it down to a set of variables that point to several services. Some are hosted, some are federated. The only data that this tool points to are these services. Nothing on a local geodatabase, or via file path to an eGDB connection.

''' Variables'''
inspectbl = (r".../services/Hosted/service_9a4388c5911f40e292c27ffc7fc47f17/FeatureServer/0")
locattbl = (r".../services/Hosted/service_9a4388c5911f40e292c27ffc7fc47f17/FeatureServer/1")
aliquot = (r".../services/WYSO_Mobile/.../FeatureServer/3")
section = (r".../services/WYSO_Mobile/.../FeatureServer/1")
twnship = (r".../services/WYSO_Mobile/.../FeatureServer/0")
admu = (r".../services/admin_boundaries/.../MapServer/3")

If I comment these out, it publishes fine. Of course, that means that I can't use the tool because I commented out these variables and can't uncomment them. once they're up there.

I thought it might be a problem that I was pointing to services on a different server, so I tried publishing with the hosted services commented out, and it still broke.

 

A colleague suggested just popping these into a JSON file, plugging that in as a parameter, and then parsing it, but that seems like an unnecessary step? 

How do I get around this?

 

Thanks everyone.

 

 

0 Kudos
1 Solution

Accepted Solutions
AlfredBaldenweck
MVP Frequent Contributor

Ok, I think I solved it.

I typically add a line break to my strings if they get too long, according to one of the PEPS (8?). It works just fine in a typical script.

        configJSON.value = (r"\\pretendthisisapathtomyfolder\tools"
                            r"\LAFI_Tools\LAFI_Tools_config.json")

This works great when running the tool.

However, it does NOT work when trying to upload the tool.

Switching it to a single line solves the problem and lets you upload at the expense of readbility.

        configJSON.value = (r"\\pretendthisisapathtomyfolder\tools\LAFI_Tools\LAFI_Tools_config.json")

I'm willing to bet this was the problem the whole time, even when I was just listing the datasources as variables.

 

View solution in original post

0 Kudos
4 Replies
AlfredBaldenweck
MVP Frequent Contributor

Update: I tried the config json. The tool runs fine. Analyzing tells me it needs to copy the json file to the server, no biggy. 

Still fails, same error.

0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi,

When you trying to publish web tool code, ArcGIS makes revision of your code and makes some changes in it. The mangling happens because ArcGIS is trying to do some kind of validation of "path-like strings" against what data sources are registered on ArcGIS Server. Check for differences with your original code.

It is recommended all paths make as parameters for tool. Then you can setup these parameters as constants and don't need to specify each time you run tool.

0 Kudos
AlfredBaldenweck
MVP Frequent Contributor

Thanks for the reply.

You mentioned checking for differences with my original code. How do I do that? It doesn't spit out a copy for me to look at, does it?

I tried adding these paths as parameters and was informed that they would be copied to the server because they're not already registered with it.

Screenshot 2026-02-20 101428.png

 

Screenshot 2026-02-20 101643.png

Screenshot 2026-02-20 101709.png

I'm having a hard time expressing how utterly takenaback by this behaviour I am. There's no reason for it to try to copy services. That's the whole point of pointing to a URL. 

How can I get this to just publish? I don't even know why it's trying to make a map service.

 

 
 
 

 

0 Kudos
AlfredBaldenweck
MVP Frequent Contributor

Ok, I think I solved it.

I typically add a line break to my strings if they get too long, according to one of the PEPS (8?). It works just fine in a typical script.

        configJSON.value = (r"\\pretendthisisapathtomyfolder\tools"
                            r"\LAFI_Tools\LAFI_Tools_config.json")

This works great when running the tool.

However, it does NOT work when trying to upload the tool.

Switching it to a single line solves the problem and lets you upload at the expense of readbility.

        configJSON.value = (r"\\pretendthisisapathtomyfolder\tools\LAFI_Tools\LAFI_Tools_config.json")

I'm willing to bet this was the problem the whole time, even when I was just listing the datasources as variables.

 

0 Kudos