public class KafkaSettingsRecord extends PersistentRecord {
public static final RecordMeta<KafkaSettingsRecord> META = new RecordMeta<KafkaSettingsRecord>(
KafkaSettingsRecord.class, "KafkaSettingsRecord").setNounKey("KafkaSettingsRecord.Noun").setNounPluralKey(
"KafkaSettingsRecord.Noun.Plural");
public static final IdentityField Id = new IdentityField(META);
//Kafka Settings
public static final StringField BrokerList = new StringField(META, "Brokers", SFieldFlags.SMANDATORY);
public static final BooleanField Enabled = new BooleanField(META, "Enabled").setDefault(false);
public static final BooleanField UseStoreAndFwd = new BooleanField(META, "UseStoreAndFwd").setDefault(false);
public static final BooleanField UseSSL = new BooleanField(META, "UseSSL").setDefault(false);
If anyone has experienced a similar issue in the past and has a way to fix it through code (not reseting the gateway) I’d appreciate the help fixing this non-critical, but visually very annoying problem.
I think this has been a development issue since the beginning… there is no fix I’m aware of aside from restarting the gateway, and there is no fix coming until this entire SORM/record system doesn’t exist any more in Ignition 8.2.
edit: although the underlying issue may be in the BundleUtil stuff… which is not part of the SORM system… hmm.
Don’t use BundleUtil with PersistentRecord properties. They load themselves. Name the properties file the same as the record’s class name with localization suffixes then .properties.
You’ll still need to restart the gateway if you modify the properties file, but otherwise should work automatically.
I have never been able to resolve the issue of field names not appearing and have spent a good amount of time going over it without success so I'm coming back here once more.
The issues are in 2 places:
1 - Config and Status Screen Labels
2 - Configuration Fields
The resource structure looks like this:
a bundle is created and removed on start and shutdown in the gateway hook. Things such as the panel title are referenced like this:
public KafkaSettingsPage(final IConfigPage configPage){
super(configPage, null, new LenientResourceModel("kafka.nav.settings.panelTitle"),
((IgnitionWebApp) Application.get()).getContext().getPersistenceInterface().find(KafkaSettingsRecord.META, 0L)
);
}
I always get this error when loading the module which I think is related to the issue but I cannot prevent it from occurring so far:
java.util.MissingResourceException: Can't find bundle for base name com/walmart/ignition/gateway/kafka/kafka, locale en_US
Construct links for each .properties with the same name but suffixes _en and _en_US. It isn’t really a proper bundle for Ignition without the localization suffixes. At least, that’s what I’ve been doing for ages now.
{ I see I’m repeating myself. You didn’t take this earlier advice. }
It's not that I didn't take the advice, I'm just confused because I am trying to follow the SDK webpage example module (whose labels works perfect). I don't see _en_US anywhere in the SDK examples.
Gateway Webpage Example File Structure
Usage in Code
public static final ConfigCategory CONFIG_CATEGORY =
new ConfigCategory("HomeConnect", "HomeConnect.nav.header", 700);
I don't know what you mean by "construct links". Could you potentially show an example?
I think there’s something else going on here. I’m currently building my modules without the language suffixes (correctly or not) and am able to get bundles working properly on my English language only system.
Are you restarting after your changes? I always make sure to uninstall/restart whenever messing with bundles.
As you’ve identified, your two issues are separate from each other - the KafkaSettingsRecord.properties is loaded for you, but your kafka.properties needs to be loaded yourself. Can we see your kafka.properties contents and your BundleUtil::addBundle call?
@bmusson I have tried the restart gateway thing but it never helps. In general its also not a solution that we’d want to rely on anyways because more often than not, we cannot just reset a server when we want since it will cause customer interruptions.
Here is the contents of kafka.properties:
We simply try to mimic what is in the gateway webpage example
Here is where where Bundle Util is called at Gateway Hook Startup
@Override
public void setup(GatewayContext gatewayContext) {
this.context = gatewayContext;
log.debug("Beginning setup of Kafka module");
BundleUtil.get().addBundle("kafka", getClass(), "kafka");
Here is where the bundle is removed at shut down
@Override
public void shutdown() {
scriptModule.shutDownSinks();
this.context.getAlarmManager().removeListener(this.alarmFilter, alarmListener);
BundleUtil.get().removeBundle("kafka");
log.info("Successfully removed data sinks from kafka module!");
}
I’ve been trying to get these darn labels to work for a long time by looking at the gateway webpage module as a reference but so far I have been unsuccessful.
To IA’s credit, the gateway webpage example loads the labels perfectly the first time…
Sorry for not replying back then. I did try when you suggest it back then and I tried again today but this didn't work.
I am working in a gateway where I can restart freely (non-production use) and after I installed the new build, restarted via EAM. Unfortunately it doesn't make the labels appear correctly.
I never did find the exact reason, but I ended up rebuilding the module from the gateway webpage example and then things started to show up correctly. Since all the code was copy and pasted over, it feels more like a project property/POM/other issue rather than any issue with the code itself.
In any case, the result is all that matters and it works now so I’m satisfied with that.
java.util.MissingResourceException: Can't find bundle for base name <module_name_here>, locale en_US
I tried add .classLoader() when registering the GatewayHook.class with BundleUtils, duplicating my property files with _en and _en_US suffixes, tried restarting the Ignition gateway service and still I get badly formatted labels on the gateway config page.
I started this whole process off by cloning the gateway-webpage module, building it and adding it to the gateway. Then I used Maven to set up a brand new project based off of the client-designer-gateway archetype, like so:
(quotes were requred around the flags and values on Windows)
I then went step by step through the gateway-webpage project and did the same thing for my new project. I was able to build a module, but now what I'm stuck at is none of the labels showing correctly.
@Kevin.Herron@pturmel when you say restart the gateway, you mean the Ignition service not the host machine, right?
I ended up resolving this issue by browsing the forums a little more and finding this comment by @Kevin.Herron that was key in fixing the label problems for me:
I cloned the gateway-webpage example (and added it as a module to my gateway to see how it works) and then immediately created a new project based on the client-designer-gateway-archetype. This then requires you to either set up a directory or package structure and for me, the issue was that the java and resources directories weren't 100% mirrored so some of the properties weren't being found.
Also, another thing that was tripping me up was that, for instance, in GatewayHook.java, we import the SettingsPage and SettingsRecord classes, but when you reference properties in that file (like nav.header and nav.settings.title - two of the labels that showed up incorrectly for me), they're actually coming from HomeConnect.properties, NOT HCSettingsRecord.properties.
If you set up everything correctly and you still get incorrect labels, you might need to do a gateway service restart. I restarted so many times (and repackaged the module) I don't know whether it would've worked the first time without a restart even if I had set everything up correctly.