I am working with the com.inductiveautomation.ignition.gateway.alarming.AlarmManager class. When I call the acknowledge method, I get the following error in the logs:
java.lang.NoSuchMethodError: com.inductiveautomation.ignition.gateway.alarming.AlarmManager.acknowledge(Ljava/util/Collection;Lcom/inductiveautomation/ignition/common/alarming/EventData;)V
I’ve doublechecked my object scopes and types and everything seems to be working properly - even other methods within the alarmManager object such as getEvents(). Any ideas what else to check? I’m using SDK version 7.8.4.
You’ll have to show your code – especially how you are constructing the arguments to acknowledge(). Jython-to-java argument conversions only work for the most common data types.
Here is the source for my method. It takes the alarm code (6-digit “reply to acknowledge” number), the phone number that sent the alarm code (to check it came from the user to which it was sent), and a timestamp.
private void acknowledgeAlarm(final String alarmCode, final String incomingNumber, final Date ackTime) {
synchronized (alarmCodes) {
if (!alarmCodes.containsKey(alarmCode)) {
log.warn("Received an incoming SMS for an alarm code that is not registered: '" + alarmCode + "'.");
return;
}
AwaitingAcknowledgement ack = alarmCodes.get(alarmCode);
User user = ack.user;
if (incomingNumberBelongsToUser(incomingNumber, user)) {
alarmCodes.remove(alarmCode);
PropertySet associatedData = new PropertySetBuilder()
.set(CommonAlarmProperties.AckUser, user.getPath())
.set(CommonAlarmProperties.AckTime, ackTime)
.build();
List<AlarmEvent> alarmEvents = ack.alarmEvents;
alarmManager.acknowledge(
Collections2.transform(
Collections2.filter(alarmEvents, new Predicate<AlarmEvent>() {
@Override
public boolean apply(AlarmEvent alarmEvent) {
return !alarmEvent.isAcked();
}
}),
new Function<AlarmEvent, UUID>() {
@Override
public UUID apply(AlarmEvent alarmEvent) {
return alarmEvent.getId();
}
}),
new EventData(associatedData));
return;
} else {
log.debug("The number " + incomingNumber + " does NOT belong to the alarm code " + alarmCode);
}
}
}
That sure looks like it should work. I’m stumped.
Your error message says that it is failing to find a match for L…Collection, L…EventData. There shouldn’t be an ‘L’ for EventData. Double check all of your error paths, and double check that you haven’t inadvertently gotten an old version of your module stuck in the gateway. A reboot might be in order.
My current installed version of Java is 1.8.0
I am developing in eclipse where I was using Ant Builds for a long time.
This current project is one I am modifying and was started by someone else and uses Maven. Any possibility I have a version issue between my SDK libraries (I may still have SDK 7.7 on my local machine, though I have Ignition Gateway 7.9.3 installed on the same machine.) or Java versions? I thought that the Maven build would grab the libraries I needed for the project.
I’m new to Maven so I’m not sure where to look in my pom files to make sure everything checks out.
I meant that the running gateway service that produced your error message may not have unloaded an earlier version of your code. (That’s another problem to look into – making sure module shutdown removes all listeners of old code.) Which would require a service restart to get just the latest version to run properly.
As for Maven, I’m not a fan. At all. It breaks all of the techniques I use to have single module files loadable in multiple versions of Ignition. I run custom Ant builds for all of my modules.
I had the same problem in Eclipse. I created a workspace with a new Maven Project and used groupid: com.inductiveautomation.ignitionsdk and artifact id: client-designer-gateway-archetype. In de pom.xml file, in the top project folder, this section is generated:
< properties>
< ignition-sdk-version>7.7.5< /ignition-sdk-version>
< /properties>
This causes the error described by you. Apparently that version of the AlarmManager does not yet have the function void acknowledge(Collection, EventData).
After changing this to below acknowledging worked.
< properties>
< ignition-sdk-version>7.9.3< /ignition-sdk-version>
< /properties>
Note that I added spaces to the xml to be able to post it here!
The funny thing I noticed is that code completion in Eclipse does suggest the acknowledge function.
In the pom file of the “build” subproject there is the < requiredIgnitionVersion>7.7.0< /requiredIgnitionVersion> tag but changing this does not generate an error during the build with maven, which I expected to occur.
Yes, the method signature changed between 7.7 and 7.9.
Use a code formatting block next time (3 back ticks):
<properties>
<ignition-sdk-version>7.9.3</ignition-sdk-version>
</properties>
This just makes an entry in the XML file embedded with your module and is used when the gateway loads your module. It's not a compile time property in any way.