java.lang.ClassNotFoundException Using AWS JDK

Hi,

I am new to Ignition module development. I am trying to create some tags and then publish the tag values to AWS CloudWatch using AWS JDK.

This is the link of my project.

I am using “com.amazonaws.services.cloudwatch.model.Dimension” to create Dimension. But when I installed the module to Ignition platform, there is an ERROR:

Caused by: java.lang.ClassNotFoundException: com.amazonaws.services.cloudwatch.model.Dimension

Full ERROR:

java.lang.NoClassDefFoundError: com/amazonaws/services/cloudwatch/model/Dimension

at com.inductiveautomation.ignition.examples.mtp.ManagedProviderGatewayHook.readAndPublishTags(ManagedProviderGatewayHook.java:192)

at com.inductiveautomation.ignition.examples.mtp.ManagedProviderGatewayHook.startup(ManagedProviderGatewayHook.java:128)

at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$LoadedModule.startup(ModuleManagerImpl.java:2386)

at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.startupModule(ModuleManagerImpl.java:1200)

at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$2.call(ModuleManagerImpl.java:737)

at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.executeModuleOperation(ModuleManagerImpl.java:922)

at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.installModuleInternal(ModuleManagerImpl.java:700)

at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$InstallCommand.execute(ModuleManagerImpl.java:1893)

at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$Receiver.receiveCall(ModuleManagerImpl.java:1842)

at com.inductiveautomation.ignition.gateway.redundancy.QueueableMessageReceiver.receiveCall(QueueableMessageReceiver.java:47)

at com.inductiveautomation.ignition.gateway.redundancy.RedundancyManagerImpl.dispatchMessage(RedundancyManagerImpl.java:912)

at com.inductiveautomation.ignition.gateway.redundancy.RedundancyManagerImpl$ExecuteTask.run(RedundancyManagerImpl.java:984)

at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:518)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: java.lang.ClassNotFoundException: com.amazonaws.services.cloudwatch.model.Dimension

at java.base/java.net.URLClassLoader.findClass(Unknown Source)

at com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:37)

at java.base/java.lang.ClassLoader.loadClass(Unknown Source)

at com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader.loadClass(ModuleClassLoader.java:85)

at java.base/java.lang.ClassLoader.loadClass(Unknown Source)

... 19 common frames omitted

I think the reason maybe the dependency version. But I tried several version of com.amazonaws. The error still comes out.

The SDK is JAVA 11,

I don’t see any dependencies for this SDK in your gateway pom.xml file.

Do you mean the “com.amazonaws” in gateway pom.xml?
I think I do have it. Is this right?

<dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.819</version>
        </dependency>

Ah, I missed that. Was looking at the bottom of the section.

When you build your module are all the dependency JAR files you expect present? Ignition .modl files are just zip files - you can open it up and investigate.

Thanks for your help.
I solve this issue by replacing

       <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.819</version>
        </dependency>

TO

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk-bom</artifactId>
                <version>1.11.819</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.819</version>
        </dependency>

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-cloudwatch</artifactId>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-cloudwatchmetrics</artifactId>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-events</artifactId>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-logs</artifactId>
        </dependency>
  <dependencies>

I have no idea why

       <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.819</version>
        </dependency>

does not work in this module.

:fearful::fearful::fearful::fearful::fearful::fearful::fearful:

To correct my answer.
The problem is not in the dependency.
The issue occurs when I use mvn install.
But disappears when I use mvn package.

Not know the exact reason yet.
:confused::confused::confused::confused:

Hmm. Were you relying on mvn install posting the module to the Ignition gateway that is configured in developer mode?

I thought we had removed that functionality because it didn’t work right. Stick to using mvn package and installing the module yourself.

Got it. I used to use mvn install. It works for me if I did not import other pacakges. (Only use ignition sdk).

Thanks for your help.
Appreciate