Jar methods not found but is

Problem accessing a method in jar:

factory = createObject('java','com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory',ExpandPath( "." ));
SerialParameters = createObject('java','com.intelligt.modbus.jlibmodbus.serial.SerialParameters',ExpandPath( "." )).init();

// this line throws error:
modbusMasterObj = factory.createModbusMasterTCP(SerialParameters);

I’m obviously not doing something correct. But the error message is referencing an interface on ModBusMasterFactory that does exist.

Did you really mean the createModbusMasterTCP() method? That one doesn’t take the serialParameters object as an argument, only TcpParameters.

You error suggests you were actually trying the createModbusMasterRTU() method, but the following seemed to work ok for me. Does it differ from what you have in any way?

factory = CreateObject( "java", "com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory", ExpandPath( "." ) );
serialParameters = CreateObject( "java", "com.intelligt.modbus.jlibmodbus.serial.SerialParameters", ExpandPath( "." ) );
master = factory.createModbusMasterRTU( serialParameters );
dump( master );

Thanks for your help that was driving me crazy. Your code worked perfect.

Only difference in our code is when I did the createobject I did this:



, ExpandPath( "." ) );
SerialParameters = createObject('java','com.intelligt.modbus.jlibmodbus.serial.SerialParameters',['jlibmodbus-']).init()>

which throws:

factory = createObject('java','com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory',ExpandPath( "." ));

//SerialParameters = createObject('java','com.intelligt.modbus.jlibmodbus.serial.SerialParameters',ExpandPath( "." ))
SerialParameters = createObject('java','com.intelligt.modbus.jlibmodbus.serial.SerialParameters',['jlibmodbus-']).init()

modbusMasterObj = factory.createModbusMasterRTU(SerialParameters);
dump( modbusMasterObj );

No matching Method for createModbusMasterRTU(com.intelligt.modbus.jlibmodbus.serial.SerialParameters) found for com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory

What do you think was wrong about loading the class it via ['jlibmodbus-']).init() ?

I’m not really sure (I’m not a java expert), but clearly all of the dependencies need to be available when instantiating the SerialParameters class.