Native libraries inside JAR file and temp directories in Lucee

Hello friends. I have developed a Java library that interacts with Tezos blockchain. With it, it is possible to create Tezos Wallets, send/receive funds and so on. The name of the project is TezosJ SDK and it is available at GitHub in two flavors: Android and Plain Java.

Now I want to add this library to Lucee and/or Coldfusion. So that it becomes even easier to interact with Tezos blockchain through CFML.

Well, I’ve put my library JAR file in Lucee lib folder. But when I instantiate the TezosWallet class, I receive an error.

<cfset tz = createObject("java", "milfont.com.tezosj.model.TezosWallet").init("password")>

Error:

Unable to load library "c:\lucee\tomcat\temp\nativeutils108923728\libsodium27362.dll": 
  Native Library (win32-x86-64)/C:\lucee\tomcat\temp\native108923728\libsodium27362.dll) not found in resource path....

Occurs that I use LazySodium inside my JAR and it creates a temp folder in the filesystem, where it copies the DLL file and then NativeLoad it.

I know… Seems complicated. But it works flawlessly in Eclipse with Windows.

Any clue?

Thank you in advance.

1 Like

This doesn’t address your question, but copying jars directly to the lib folder isn’t usually recommended these days. Use this.javaSettings in Application.cfc

So on to your question, can you confirm the first obvious question, which is does the user running Lucee have read/write access to the directory in question. And secondly, if you look in that folder, is the DLL there? What happens if you hardcode the path to another directory just as a test?

Also, why are these two paths different in the error message:

c:\lucee\tomcat\temp\nativeutils108923728\libsodium27362.dll
C:\lucee\tomcat\temp\native108923728\libsodium27362.dll

Thank you for taking the time to answer. I will try to change my code according to your suggestions. About the different error messages, never mind, it is a typo.

My project uses LazySodium library, which unpacks at runtime libsodium.dll from the JAR. That dll is a native C++ library with cryptography functions. LazySodium tries to grab the configured temp directory from the system. Maybe if the JAR is put in the tomcat/lib folder, it is using the tomcat’s configured temp path, instead of Lucee’s temp path. I think there’s a logic there. I will work with this. Then I post resuts.

It was something related with Windows Server R8 2008 operating system. Something related to temp folders permision. I’ve tested it on Windows 10 and it worked. Check it out:
https://www.reddit.com/r/tezos/comments/9a0j27/tezos_in_coldfusionlucee_tested_with_tezosj_sdk/