Question
· Jun 20, 2018

%ProcessError+6 ^%Net.Remote.Proxy.1 error occurs inconsistently

Hi

 
I'm trying to learn me working with .NET libraries and Ensemble. 
 
I have made a very simple .Net dll which just simple write a text to a file.
 
I have import the libraries in the studio , putted up a EnsLib.DotNetGateway.Service in my namespace. Everything by the book. The EnsLib.DotNetGateway.Service starts fine and i trigger the simple call by a fileinbound.adapter (tried in normal class as well. But i'm stuck in a error message i can't figure out what is wrong.
 
This is the error message:
 
"ERROR <Ens>ErrException: <ZJGTW>%ProcessError+6 ^%Net.Remote.Proxy.1 -- logged as '-'

number - @''"

 
 
The code to call is simple:
 

Set conn ##class(%Net.Remote.Gateway).%New()  // No error here
Set tSC conn.%Connect("127.0.0.1""55000""NETTEST"// No error here
Set api ##class(writetofile.WriteFile).%New(conn) //Here comes the error
set strFile "d:\temp\example.txt"
set strInput "Hello world"
set ret api.FilePut(strFile,strInput)
Set tSC conn.%Disconnect()
 
If i just connect and disconnet to the Net.Remote.Gateway no error
 
Here is the proxy classe
 
Class writetofile.WriteFile Extends System.Object ProcedureBlock ]
{

Parameter IMPORTTIMESTAMP As STRING = "2013-07-17 16:40:43";

Method %OnNew(ByRef p0 As %ObjectHandleAs %Status
{
If '$D(p0If ($IO["TCP"Quit $$$OK Else Set x=$$$ERROR($$$RemoteGatewayError,"Gateway instance must be supplied"Zt "JGTW" }
Quit ..%Constructor(p0,"writetofile.WriteFile",0)
}

Method getuFileText() As %ObjectHandle
{
Quit ..%IR("get_FileText")
}

Method setuFileText(ByRef p0 A%ObjectHandle)
{
Do ..%I("set_FileText",.p0)
}

Method getuFilePath() As %ObjectHandle
{
Quit ..%IR("get_FilePath")
}

Method setuFilePath(ByRef p0 A%ObjectHandle)
{
Do ..%I("set_FilePath",.p0)
}

Method FilePut(ByRef p0 As %ObjectHandleByRef p1 As %ObjectHandle)
{
Do ..%I("FilePut",.p0,.p1)
}

}
 
 
Can anybody se whats wrong?
Discussion (10)0
Log in or sign up to continue

you miss a check in your code

Set conn ##class(%Net.Remote.Gateway).%New()  // No error here
Set tSC conn.%Connect("127.0.0.1""55000""NETTEST"// No error here
 IF 'tSC  ...........  // check if connection was succesful
Set api ##class(writetofile.WriteFile).%New(conn) //Here comes the error
set strFile "d:\temp\example.txt"
set strInput "Hello world"
set ret api.FilePut(strFile,strInput)
Set tSC conn.%Disconnect()

Your connection may have failed, so next call will fail too, 

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
}

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()-  */

I was unable to identify the class System.Object you inherit for your proxy object.

But the methods you call are all available in  %Net.Remote.Proxy

so verify the definition of System.Object
or change your class to

Class writetofile.WriteFile Extends  %Net.Remote.Proxy  ProcedureBlock ]

I think you fail in %OnNew() in ..%Constructor(..)

I might be worth for testing to replace

Quit ..%Constructor(p0,"writetofile.WriteFile",0)

by 

Try {
     set obj=..%Constructor(p0,"writetofile.WriteFile",0)
}
Catch erroor  {.....   set obj=""}

Quit obj

method %ProcessError should output the real error but what you see is the result of ZT "JGTW"

Method %ProcessError(
fun As %String,
msgid As %Integer) [ Final ]
{
Use ..Gateway.GatewayDevice 
If fun="Y9" Do ..%ReadObjects(..Gateway) Quit
Set error=$zobjexport(12)
Set x=$$$ERROR($$$RemoteGatewayError,error)   
Use ..Gateway.CurrentDevice
Zt "JGTW"
}

 

Your error lands in the highlighted line. But as the method is FINAL you can't overload it.
Your original class System.Object might be a less restricted copy.

In addition, I see ZTRAP command this may explain why Try / Catch didn't react as expected.  

Do you catch exceptions?

If not try this:

Try {
 Kill %objlasterror
 Set conn = ##class(%Net.Remote.Gateway).%New()  // No error here
 Set tSC = conn.%Connect("127.0.0.1", "55000", "NETTEST") // No error here
 Write:$$$ISERR(tSC) $System.Status.GetErrorText(tSC),!
 ZWrite %objlasterror 
 Set api = ##class(writetofile.WriteFile).%New(conn) //Here comes the error
 ZWrite %objlasterror 
 Set strFile = "d:\temp\example.txt"
 Set strInput = "Hello world"
 Set ret = api.FilePut(strFile,strInput)
 Set tSC = conn.%Disconnect()
 Write:$$$ISERR(tSC) $System.Status.GetErrorText(tSC)
} Catch ex {
 ZWrite %objlasterror
 Do ex.Log()
 Write ex.DisplayString(),!
}

%objlasterror  can contain more error information. Also check application error log.

Are you on 32 or 64 bits? Check Cache with:

Write $system.Version.Is64Bits()

.Net library should be compiled with the same architecture.