I am trying to publish a geoprocessing service, but it fails.
Both ArcGIS Enterprise (10.8.1) and ArcGIS Desktop (10.8.1) are on the same machine

The output of the results window in ArcGIS Desktop shows this:
Stage Service - Passes
Upload Service Definition - Failed
Results Window
The logs from server show the following:
Error Code=9999 - java.rmi.UnmarshalException: Error unmarshaling return header
<Msg time="2022-10-30T12:51:25,570" type="INFO" code="9526" source="Soap" process="6772" thread="20" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="f5fc75cf-b5ce-4c6b-b33e-34fa08a6d7fd">Request for the service 'System/PublishingTools.GPServer' processed successfully. Response sent to the user '0123456789ABCDEF::myname'.</Msg>
<Msg time="2022-10-30T12:51:25,570" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="f5fc75cf-b5ce-4c6b-b33e-34fa08a6d7fd">Server object processing time for service request: System.PublishingTools.GPServer is 5 ms.</Msg>
<Msg time="2022-10-30T12:51:25,716" type="SEVERE" code="7551" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">Instance of the service 'System/PublishingTools.GPServer' crashed. Please see if an error report was generated in 'C:\arcgis\arcgisserver\logs\MACHINEACTUALNAME\errorreports'. To send an error report to Esri, compose an e-mail to ArcGISErrorReport@esri.com and attach the error report file.</Msg>
<Msg time="2022-10-30T12:51:25,717" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.net.SocketException: Connection reset
at java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at java.rmi/sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at com.sun.proxy.$Proxy18.handleRequest(Unknown Source)
at com.esri.arcgis.discovery.admin.rediscovery.service.ArcSOCGISService.handleRequest(ArcSOCGISService.java:598)
at com.esri.arcgis.discovery.admin.rediscovery.actors.GPServerObjectSyncActor.onReceive(GPServerObjectSyncActor.java:156)
at akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(UntypedActor.scala:167)
at akka.actor.Actor$class.aroundReceive(Actor.scala:467)
at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:97)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.net.SocketException: Connection reset
at java.base/java.net.SocketInputStream.read(Unknown Source)
at java.base/java.net.SocketInputStream.read(Unknown Source)
at java.base/java.io.BufferedInputStream.fill(Unknown Source)
at java.base/java.io.BufferedInputStream.read(Unknown Source)
at java.base/java.io.DataInputStream.readByte(Unknown Source)
... 19 more
</Msg>
Error Code=9999 - java.rmi.UnmarshalException: Connection refused to host: localhost
<Msg time="2022-10-30T12:51:26,603" type="INFO" code="9526" source="Soap" process="6772" thread="20" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="671d635e-df81-4f91-aed9-68f359ce9a11">Request for the service 'System/PublishingTools.GPServer' processed successfully. Response sent to the user '0123456789ABCDEF::myname'.</Msg>
<Msg time="2022-10-30T12:51:26,602" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="671d635e-df81-4f91-aed9-68f359ce9a11">Server object processing time for service request: System.PublishingTools.GPServer is 6 ms.</Msg>
<Msg time="2022-10-30T12:51:26,720" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at java.rmi/sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi/java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at com.sun.proxy.$Proxy18.shutdown(Unknown Source)
at com.esri.arcgis.discovery.admin.rediscovery.service.ArcSOCGISService.stop(ArcSOCGISService.java:498)
at com.esri.arcgis.discovery.admin.rediscovery.service.ArcSOCGISService.start(ArcSOCGISService.java:282)
at com.esri.arcgis.discovery.admin.rediscovery.service.ArcSOCGISService.handleRequest(ArcSOCGISService.java:661)
at com.esri.arcgis.discovery.admin.rediscovery.actors.GPServerObjectSyncActor.onReceive(GPServerObjectSyncActor.java:156)
at akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(UntypedActor.scala:167)
at akka.actor.Actor$class.aroundReceive(Actor.scala:467)
at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:97)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.net.ConnectException: Connection refused: connect
at java.base/java.net.PlainSocketImpl.connect0(Native Method)
at java.base/java.net.PlainSocketImpl.socketConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at java.base/java.net.Socket.<init>(Unknown Source)
at java.base/java.net.Socket.<init>(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPDirectSocketFactory.createSocket(Unknown Source)
... 23 more
</Msg>
<Msg time="2022-10-30T12:51:26,720" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">Shutting down context for service: System.PublishingTools.GPServer</Msg>
<Msg time="2022-10-30T12:51:26,720" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">Cleanup: Terminating SOC process. System.PublishingTools.GPServer</Msg>
.
Error Code=9999 - java.lang.Exception: Could not service request
<Msg time="2022-10-30T12:51:37,977" type="INFO" code="9526" source="Soap" process="6772" thread="20" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="86b57c7d-a9da-49d0-be34-e529e617d4cb">Request for the service 'System/PublishingTools.GPServer' processed successfully. Response sent to the user '0123456789ABCDEF::myname'.</Msg>
<Msg time="2022-10-30T12:51:38,748" type="DEBUG" code="9999" source="System/PublishingTools.GPServer" process="34100" thread="22" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">End server object construction. CLSID = {a6da33b7-4804-4116-b54d-a72d77dd4081}</Msg>
<Msg time="2022-10-30T12:51:38,748" type="DEBUG" code="9999" source="System/PublishingTools.GPServer" process="34100" thread="22" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">Server object implements IObjectActivate.</Msg>
<Msg time="2022-10-30T12:51:38,749" type="DEBUG" code="9999" source="System/PublishingTools.GPServer" process="34100" thread="22" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">Server object implements IRequestHandler2.</Msg>
<Msg time="2022-10-30T12:51:38,749" type="INFO" code="8000" source="System/PublishingTools.GPServer" process="34100" thread="22" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="7621.0" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">Instance of service 'System/PublishingTools' has been created successfully.</Msg>
<Msg time="2022-10-30T12:51:38,806" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea"> Exception in com.esri.arcgis.discovery.admin.rediscovery.actors.GPServerObjectSyncActorcom.esri.arcgis.discovery.admin.rediscovery.util.ArcGISServiceException: Could not service request.</Msg>
<Msg time="2022-10-30T12:51:38,806" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">java.lang.Exception: Could not service request.
at com.esri.arcgis.discovery.admin.rediscovery.actors.RediscoveryAppServer.handleRequestNoWait(RediscoveryAppServer.java:466)
at com.esri.arcgis.discovery.admin.rediscovery.actors.GPJobExecutorSingleton.a(GPJobExecutorSingleton.java:327)
at com.esri.arcgis.discovery.admin.rediscovery.actors.GPJobExecutorSingleton.access$1300(GPJobExecutorSingleton.java:68)
at com.esri.arcgis.discovery.admin.rediscovery.actors.GPJobExecutorSingleton$ExecutorThread.run(GPJobExecutorSingleton.java:520)
</Msg>
<Msg time="2022-10-30T12:51:38,806" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">Exception caught while handling request for service -System/PublishingTools.</Msg>
<Msg time="2022-10-30T12:51:38,806" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">java.lang.Exception: Could not service request.</Msg>
<Msg time="2022-10-30T12:51:38,806" type="SEVERE" code="7553" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">The containing process for 'System/PublishingTools' job 'j9abdea8d57b94ac2b2413cda4a482d9b' has crashed.</Msg>
<Msg time="2022-10-30T12:51:38,819" type="VERBOSE" code="7718" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="e08dc073-bd06-4d5d-87fa-889601fa35ea">Job 'j9abdea8d57b94ac2b2413cda4a482d9b' for service 'System/PublishingTools' completed its execution. The status of the job after completion was 'esriJobFailed'. Elapsed time '87419' ms.</Msg>
<Msg time="2022-10-30T12:51:38,982" type="DEBUG" code="8521" source="Server" process="6772" thread="27" methodName="WebSecurityManager.authenticate" machine="MACHINEACTUALNAME" user="0123456789ABCDEF::myname" elapsed="" requestID="d886a6f7-46c3-442a-a15b-fcfb936787a2">HTTP Referer: http://www.esri.com/90370070-030B-49AD-BE5F-CF058F651497</Msg>
<Msg time="2022-10-30T12:51:38,982" type="INFO" code="9502" source="Soap" process="6772" thread="20" methodName="" machine="MACHINEACTUALNAME" user="0123456789ABCDEF::myname" elapsed="" requestID="d886a6f7-46c3-442a-a15b-fcfb936787a2">Request received from the user '0123456789ABCDEF::myname' for the service 'System/PublishingTools.GPServer'.</Msg>
<Msg time="2022-10-30T12:51:38,982" type="DEBUG" code="9999" source="Server" process="6772" thread="27" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="d886a6f7-46c3-442a-a15b-fcfb936787a2">RediscoveryAppServer handleRequest called. FQSN: System.PublishingTools.GPServer</Msg>
<Msg time="2022-10-30T12:51:38,982" type="DEBUG" code="9999" source="Soap" process="6772" thread="20" methodName="" machine="MACHINEACTUALNAME" user="" elapsed="" requestID="d886a6f7-46c3-442a-a15b-fcfb936787a2">Binary request for service - System/PublishingTools.GPServer</Msg>
I have tried a number of solutions but I am unable to resolve this issue. Any pointer are welcomed.