Facing issues while returning the object from another class in Java action
0
Hi Team, I'm currently facing an issue while attempting to return the txBuffer and rxBuffer string values, which are attributes of the ConnectionTCP class object, from external class files using a Java action in Mendix. I've created a JAR file, imported it into our project's userlib folder, and successfully tested the code in Eclipse IDE. However, when executing the same code from a custom Java action in Mendix, I'm unable to obtain the expected result. Instead, I'm getting a null value as a result. For your reference, I'm providing the relevant code snippet below. Can anyone help me identify and fix the issue? Code : RFID ref = new RFID(); IMendixObject data = Core.instantiate(getContext(), "MyFirstModule.Data"); ConnectionTCP connectiontcp = new ConnectionTCP(); try { connectiontcp = ref.exchangeData(IP, Math.toIntExact(Port), connectiontcp); ILogNode logger = Core.getLogger("Trace the log : TxBuffer"); logger.info("Info log message"); if (connectiontcp == null) { connectiontcp.txBufferStr = "Empty value"; } logger.info("Variable value: " + connectiontcp.txBufferStr); data.setValue(getContext(), "TxBuffer", connectiontcp.txBufferStr); data.setValue(getContext(), "RxBuffer", connectiontcp.rxBufferStr); Core.commit(getContext(), data); return data; } catch (Exception e) { e.printStackTrace(); ILogNode errorLogger = Core.getLogger("ErrorLogger"); errorLogger.error("Exception during data exchange: " + e.getMessage()); return data; }