Exception on SettingsModel validateSettings

I’m implementing a node following the NumberFormatter example and I’m getting this exception

ERROR	 ModalContext Node	 Loading model settings failed: Int for key "trials" not found.
org.knime.core.node.InvalidSettingsException: Int for key "trials" not found.

in the method

protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException

This happens when launching KNIME from Eclipse for node testing, the platform launches and the node runs, but it always uses the default options for each SettingsModel, no matter which value was set in the NodeDialog components.

This is the format that I’m using in my Node Model for the “trials” component, the remaining are the same.

//In MyNodeModel

private static final String KEY_TRIALS = "trials";
private static final int DEFAULT_TRIALS = 50000;
/*
 * Rest of the KEY/DEFAULT pairs for parameters
 */ 

SettingsModelIntegerBounded trialsSettings = createTrialsSettingsModel();
/*
 * Rest of SettingsModel instatiations
 */ 

public static SettingsModelIntegerBounded createTrialsSettingsModel() {
	return new SettingsModelIntegerBounded(KEY_TRIALS, DEFAULT_TRIALS, 0, 1000000);
}

/* 
 * Rest of SettingsModel creation methods
 */ 

This is the format of the NodeDialog

//In MyNodeDialog

SettingsModelIntegerBounded trialsSettings = MyNodeModel.createTrialsSettingsModel();
/*
 * Rest of SettingsModel instatiations
 */
addDialogComponent(new DialogComponentNumber(trialsSettings, "Number of Trials", 500));
/*
 * Rest of DialogComponent creation
 */

Hi @xandor19,

Double check if you are saving the settings in the saveValidatedSettings method?
This error looks like you are not doing that.

best,
Gabriel

1 Like

It seems that the problem was that the node was pre-loaded in my testing workflow and the issue was from previous stages of the development. After @gab1one suggestion I double-checked everything and then deleted the node from my workflow and then insert it again. Now it works.
This was my case and it’s probably because the node was in the workflow before the implementation of the method indicated by gab1one

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.