Search code examples
xpageslotus-domino

Domino Crashes when running parallell Xagent calls


We have been experiencing Domino server crashes lately. We have found that the crashes are caused by parallel calls to the same Xpage by the same user.

We have now chained the Ajax calls to the Xpage so that they are synchronous and the crashes have stopped.

As we would like to move towards more Ajax calls towards Xpages (Xagent style) in future development we would like to know why this is occurring and how to solve it. We can't find any code in the javacode that needs to be synchronized.

Is this known issue. How can we get around this issue whithout performing all calls synchronously?

Summary of solution that causes error:

A web page calls an Xpage that calls XAgent via SSJS in afterRenderResponse. Javaclass reads Post Request and send JSON back via FacesContext.

Detailed description:

We call the Xpage via Ajax POST calls. Sometimes these calls are performed toward the same Xpage by the same user in parallell. (That is when we get crashes)

IE in javascript (Angular):

Code that crashes server:

$http.post('xpage1.xsp',data1,config).then(){
     Do stuff with response from call1
 }
 $$http.post('xpage1.xsp',data2,config).then(){
         Do stuff with response from call2
 }

Code that works:

$http.post('xpage1.xsp',data1,config).then(){
       Do stuff with response from call1;
         $$http.post('xpage1.xsp',data2,config).then(){
             Do stuff with response from call2
        }
 }

where the data is just is an object containg requestdata and config is just config for the HTTP call.

The Xpage is calling the javacode in the AfterRenderResponse event of the Xpage. ((XAgent framework)

The Javacode is Using The FacesContext Object to read the request and to create a response. It Reads the JSON posted and gets a document. which it creates a Java object of .We then create new JSON from the JavaObject via GSON and send this JSON as response to browser.

        private static FacesContext faccon;
        private static ExternalContext extcon;
        private static HttpServletRequest request;
        private static HttpServletResponse response;
        private String logOn ="";
        private boolean javaDebuggingOn = false;

       public SaveCtrl() {
          faccon = FacesContext.getCurrentInstance();
          extcon = faccon.getExternalContext();
          request = (HttpServletRequest) extcon.getRequest();
          response = (HttpServletResponse) extcon.getResponse();
       }

     public void post() throws IOException {
          String processName = className + "." + "post";

          response.setHeader("Cache-Control", "no-cache");
          response.setContentType("application/json");
          response.setCharacterEncoding("UTF-8");
          response.setStatus(200); // HTTP OK

          ResponseWriter writer = faccon.getResponseWriter();
          //Handle JSON in POST  Request
          String requestBody = extractPostRequestBody(request);
          String action = requestData.get("action");


        //Send JSON response
        Gson gson = new GsonBuilder()
        .setDateFormat("yyyy-MM-dd HH:mm:ss")
        .create();

        List myList = getList(action);
        String jsonOut= gson.toJson(myList );


        writer.write(jsonOut);


         writer.endDocument();
         faccon.responseComplete();

     }

Solution

  • The answer was that there is som error in the code reading and writing the response when this was changed to a REST component the calls are functioning in parallel.