I'm trying to register a new reporting component that I've built, and the GatewayHook class loader doesn't seem to be able to find the "AbstractJ2DShape" class. Do I need to force it to use a specific class loader?
I'm using the following dependency in my common pom.xml:
java.lang.NoClassDefFoundError: com/inductiveautomation/rm/shape/j2dshapes/AbstractJ2DShape
.........................
Caused by: java.lang.ClassNotFoundException: com.inductiveautomation.rm.shape.j2dshapes.AbstractJ2DShape
at java.base/java.net.URLClassLoader.findClass(Unknown Source)
at com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:37)
at com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader.loadClass(ModuleClassLoader.java:104)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 26 common frames omitted
I've run mvn clean install and restarted my Gateway just in case that's the problem...
That was it... I knew it was going to be something simple like that.
I do have a related question though - if I don't want my module to depend on the reporting module, is there a way I can configure that? So for instance, my module is mostly providing a back-end service on the gateway and I'm creating a few perspective/reporting components as additional "bonus" features. I don't want the module installation to fail if the end user doesn't have Reporting or Perspective installed just for these "niceties", I'd rather just add a try/catch somewhere, log a warning and move on.
The trickery is usually factoring out the reporting-specific initialization (or anything in the lifecycle) into a separate class, so that the gateway hook itself doesn't have any binary reference to the reporting module or to that separate class file. Where needed, you load that special class by name and skip if it fails.
Same idea for Perspective or any other soft dependency.