yck
yck

Reputation: 33

JNA library initialize problem in dokany java file system

Currently we are trying to adapte dokany-java (written by @jhult) repository to our project. Our goal is to use dokany virtual drive but the problem is library is not initializing in our project and also repository's example main is not working (MountMemoryFS).

The error is

java.lang.UnsatisfiedLinkError: Error looking up function 'DokanMapStandardToGenericAccess': The specified procedure could not be found.
at com.sun.jna.Function.<init>(Function.java:245)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:566)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:542)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:528)
at com.sun.jna.Native.register(Native.java:1770)
at com.sun.jna.Native.register(Native.java:1643)
at com.sun.jna.Native.register(Native.java:1360)
at com.dokany.java.NativeMethods.<clinit>(NativeMethods.java:28)
at com.dokany.java.DokanyDriver.start(DokanyDriver.java:70)
at com.dokany.java.examples.memoryfs.MountMemoryFS.main(MountMemoryFS.java:46)

Dokany version : 1.5.1 Java version : 8

How can we solve this problem?

Upvotes: 1

Views: 172

Answers (1)

Daniel Widdis
Daniel Widdis

Reputation: 9091

You have a version mismatch between your Java code and the dokan1.dll file you are using, because you are basing your code off a very old personal fork of the maintainer rather than the official upstream project at a tag matching the version you want to use.

The stack trace points to NativeMethods as the source of the problem in the dokany library:

String DOKAN_DLL = "dokan1";

static {
    Native.register(DOKAN_DLL);
}

JNA is finding the dokan1.dll file, but it is not finding the DokanMapStandardToGenericAccess method in the DLL.

Issue #620 at the dokany site indicates this method was moved as part of a 1.1.0 breaking change, and the Change Log for 1.1.0 indicates:

Library - Merge DokanMapStandardToGenericAccess with DokanMapKernelToUserCreateFileFlags

Symptoms here indicate you have a newer version of dokan1.dll which does not include this method, but you are using a pre-1.1.0 version of the java code.

You linked in your question to the maintainer's personal branch which does not indicate a version, but was last merged to the upstream project on 2017-07-03, while Release 1.1.0 was on 2020-04-23 as shown on the upstream dokan-dev/dokan version of the code. Neither of these match the current location of the dokan-dev/dokany project where 1.5.1 was published.

To solve this, use the Java code from the proper (1.5.1) tag at the correct site (or download the JAR or use a dependency manager) to match the java code to your DLL version. Or better yet, use the latest 2.x version of both code and DLL.

Upvotes: 1

Related Questions