Thanks Sam for your kind response.

The worst story is,  I don't have any other information for this error right now since this is occurring inconsistently.

WRC may help but for them also I need to have some information to reproduce.

So I thought if I get know on what basis this error throws and I can try that way to reproduce this error.  so that I can get some information on this for WRC or to post for suggestion.

Thanks Eduard. %objlasterror helped me to get the error. Below is the error I got.

"0 "_$lb($lb(5023,"Error caught by Gateway.executeInstanceMethod"_$c(13,10)_"   at InterSystems.Data.CacheClient.Gateway.Gateway.executeInstanceMethod(MethodInfo method, String methodName, String oref)"_$c(13,10)_"   at InterSystems.Data.CacheClient.Gateway.Gateway.executeMethod()"_$c(13,10)_"No more licenses are available."_$c(13,10)_"   at Xerox.Statit.StatitClass.Init()"_$c(13,10),,,,,,,,$lb(,"TEST",$lb("e^%ProcessError+4^%Net.Remote.Proxy.1^1","d^%I+11^%Net.Remote.Proxy.1^1","d^zInit+1^Xerox.Statit.StatitClass.1^1","d^zInitEServer+29^DeepSee.Portlets.IndicatorPortlet.1^1","e^zOutputChart+47^DeepSee.Portlets.IndicatorPortlet.1^1","e^zInvokeInstanceMethod+133^%ZEN.Controller.1^1","x^zInvokeInstanceMethod+133^%ZEN.Controller.1^1","e^zInvokeInstanceMethod+2^%ZEN.Component.abstractPage.1^1","e^zCSPEvent+10^%CSP.Broker.1^1","x^zCSPEvent+10^%CSP.Broker.1^1","e^zOnPage+3^%CSP.Broker.1^1","e^zPage+9^%CSP.Broker.1^2","e^CSPDispatch+449^%SYS.cspServer^2","d^CSPDispatch+284^%SYS.cspServer^1","d^zProcessRequest+1^%CSP.Session.1^1","d^Request+620^%SYS.cspServer2^1","d^Request+25^%SYS.cspServer2^1","d^zProcessRequest+1^%CSP.Request.1^1","d^css+41^%SYS.cspServer2^1","d^SuperServer+48^%SYS.SERVER^3","d^^^0"))))/* ERROR #5023: Remote Gateway Error: Error caught by Gateway.executeInstanceMethod-    at InterSystems.Data.CacheClient.Gateway.Gateway.executeInstanceMethod(MethodInfo method, String methodName, String oref)-    at InterSystems.Data.CacheClient.Gateway.Gateway.executeMethod()- No more licenses are available.-    at Xerox.Statit.StatitClass.Init()-  */

Hi Robert,

Thanks for your patience.

Below is the %OnNew method I tried with try-catch block. And I added a global reference to store the exception but global is not been set. so I think it didnt enter catch block.

Method %OnNew(ByRef p0 As %ObjectHandle) As %Status
{
set Stat=""
If '$D(p0) If ($IO["TCP") Quit $$$OK Else Set x=$$$ERROR($$$RemoteGatewayError,"Gateway instance must be supplied") Zt "JGTW" }
Try
{
set Stat= ..%Constructor(p0,"writetofile.WriteFile",0)
}
catch exc
{
set ^xKPS("exc")=exc
set Stat= exc.AsStatus()
}
quit Stat
}