I am building an opc-ua module that is using a third party library comprising a jar file and jni dll.
Can the jar file and dll be packaged in the modl file. I am new to maven, I haven't even been able to package the library using methods on this stack overflow post, Generate a runnable jar and include libraries in it with Maven - Stack Overflow
I was able to work around the jar file by placing it manually in the ignition directory /lib/core/
The jni dll is required to be placed in C:\Windows\System32. It works when I use the library in a stand alone java application, however ignition is throwing a 'java.lang.UnsatisfiedLinkError'
If the library you're using is calling System.loadLibrary
and not giving you a chance, you'll have to put the DLL somewhere on the java.library.path
. I'm pretty sure by default that includes the lib/core/gateway
folder, but you can print the value out at runtime and see for sure.
Ideally the library lets you load it yourself via System.load
, and then you can extract the DLL to a temp directory of your choice and load it explicitly.
Thanks, I've put the dll in system32 and lib/core/gateway. After restarting the ignition service, it recognized the dll.
Can anyone help with the maven packaging, or is that best suited for a maven forum?
What is it exactly you need help with?
We do have a somewhat deprecated Maven plugin to help assemble a modl
file, but I'm not sure if that's where you're at yet?
I used the example opc-ua from github that includes a maven build. I can't figure out how to include the third party jar file in the modl. Or the dll, but i'm not sure if that is even possible.
Just a standard Maven dependency entry, except it wouldn't be "provided" scope like this one:
Ideally your JAR would have the DLL packaged as a resource inside it. Not sure there's anything to help you get it into the modl
file on the plugin side.
Thanks, unfortunately I've already tried that.
I know it finds the library because it couldn't build before, but it doesn't include it in the final jar.
The Ignition maven plugin is only responsible for assembling your modl
file, not assembling your JAR or including the native library inside that JAR. This is a dependency you are presumably getting from somewhere else, and simply including/using it in your module.
I'm trying to package the 3rd party jar inside the gateway jar.
It sounds like maven can do this, as per stack-overflow topic I referenced above, but the guides haven't worked for me.
If this is more appropriate to ask in a maven forum I will take it there.
Yeah it might be more appropriate. We don't even use Maven any more, and did not attempt to package everything to together in a single JAR using the method outlined in that SO post.