Cannot access foreign servers when running on a server

I have a LS-querysave-agent(on Server A) that tries to run a java-agent on another server (Server B). Server B have access to a webservice that is used by the javaagent. Server A and Server B is in the same domain, and have allthe rights to run agents/scripts etc.

In my LS-querySave-agent I invoke the javaagent by agent.runOnServer(noteid). This generates the error “Cannot access foreign servers when running on a server”.

If I invoke the javaagent by agent.run the agent will run, but then the webservice that is accessed by the java-agent is unavailable. I tried to rewrite the querysave-agent to a scheduled agent, but that resultet in the

same errormessage (“Cannot access foreign servers when running on a server”). Does anyone have any suggestions on how I could solve this?

Appreciate any suggestions on how I could solve this

Subject: Check the trusted servers setting

Check the trusted servers field in the server document. The foreign / remote server needs to trust the server that the agent is running on.

Subject: that did not solve the problem

Updated the trusted servers field on both servers, but we still keep getting the same errormessage as earlier