Search code examples
javaxpagesagent

Run Java Agent XPage


I try to run an Java Agent in XPage. The Agent runs in the beforePageLoad Event to manipulate the current document.

 <xp:this.beforePageLoad><![CDATA[#{javascript:
          var agent:NotesAgent =database.getAgent("RedirectGroups")
          agent.runWithDocumentContext(currentDocument.getDocument())
    }]]></xp:this.beforePageLoad>

For testing the agent prints a simple message to the console.

If I run the XPage in Browser I get an error 500 message. I'm using Notes 9.01 on an Domino 9 Server

Will I have to run the agent in an other event of the XPage?


Solution

  • The agent has to have

    • Security option "Run as Web user" set
    • as Target "None"

    As the agent might run with this options it's not good practice to call a Java agent in an XPage. Better call/use the Java code direct in your XPage.