That is indeed strange. It looks like a bug to me, so I’d file a ticket with support and see if it’s possible for them to address it in a fix. Now, if I may make one small suggestion, one thing you can do to avoid exceptions due to missing global variables is to create a Java service for fetching a global variable value, and if the global variable does not exist, it returns an optional default value instead of throwing an exception. For example, I have a Java service in my common utilities package that takes in the variable name and an optional default value as input. It then performs this logic:
IDataCursor cursor = pipeline.getCursor();
try {
String name = IDataUtil.getString(cursor, "name");
String defaultValue = IDataUtil.getString(cursor, "default");
if(GlobalVariablesManager.getInstance().globalVariableExists(name)) {
String value = GlobalVariablesManager.getInstance().getGlobalVariableValue(name).getValue();
IDataUtil.put(cursor, "value", value);
}
else if(defaultValue != null) {
IDataUtil.put(cursor, "value", defaultValue);
}
}
catch(Throwable t) {
throw new ServiceException(t);
}
finally {
cursor.destroy();
}
Yet another option is to have a startup service in your package that creates the global variables it needs when the package is loaded if the global variable doesn’t exist. Here’s a snippet from one such startup service:
if(!GVM.globalVariableExists(LOGGING_VERSION_GV)) {
GVM.addGlobalVariable(LOGGING_VERSION_GV, Integer.toString(version), false);
}
GVM in this case is defined as:
private static final GlobalVariablesManager GVM = GlobalVariablesManager.getInstance();
I’ve used both approaches in the past and they work well.
Hope this helps,
Percio
#webMethods