I need some help on development in Caché's Objectscript.
I've been working in this technology for some months and since some days, I'm trying to get the Java Gateway to work without success. It is supposed to allow me to run java .class et .jar code.
But even if it is explained in the documentation, there is no full example and I'm getting errors over and over. So, I was wondering if someone can provide a full example, correct me or explain what I'm doing wrong?
Here is what I have for now:
My simple java class - write date and time in a file
package packagename.packagename2;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.time.LocalDateTime;
public class entertest {
public int enter() throws IOException
{
File file = new File("D:\\path\\filemane.txt");
if (!file.exists()) {
file.createNewFile();
}
BufferedWriter bf = new BufferedWriter(new FileWriter(file.getAbsoluteFile()));
bf.write(LocalDateTime.now().toString());
bf.close();
return 1;
}
}
My objectscript code - define my gateway and try to call the method
Class domain.java.TestJava Extends EnsLib.HL7.Service.TCPService
{
Method OnProcessInput(pLine As Ens.StringContainer, Output pLineLeftOver As Ens.StringContainer) As %Status
{
Do ##super(pLine,pLineLeftOver)
Set val = 0
$$$TRACE(val)
Set gateway = ##class(%Net.Remote.Gateway).%New()
Do gateway.%Connect("127.0.0.1", 55553)
Do gateway.%Import("D:\\path\\entertest.jar")
Set javaObj = ##class(packagename.packagename2.entertest).%New(gateway)
Set val = javaObj.enter()
$$$TRACE(val)
Quit $$$OK
}
}
I get an error :
ERREUR <Ens>ErrException: <CLASS DOES NOT EXIST>zOnProcessInput+9^domain.java.TestJava.1 *packagename.packagename2.entertest
-- - connecté en tant que '-' numéro - @' Set javaObj = ##class(packagename.packagename2.entertest).%New(gateway)'
I used this post but I don't know how he got it working: Intersystems Caché with Java Gateway - Pass parameter as java.io.FileInputStream
I tried to add a service "JavaGatewayService" in the Ensemble production. Did not help...
I also tried to add an object gateway in
System Administration > Configuration > Connectivity > Object Gateways.
Did not help... And I don't know if it should help me...
I'm out of ideas/options.
Thank you in advance.