Search code examples
javalinuxsharenfs

Access to NFS-Share from Java-Application


I am trying to access a NFS share on a CentOS 6.3 System from within a Java application. I've tried the following libraries but can't get either to work:

YaNFS

Trying to access the NFS Share with YaNFS I run into an NfsException with ErrorCode 10001 (NFSERR_BADHANDLE). Sometimes the text of the Exception says "Stale NFS file handle". My code for YaNFS is:

    public static void main(String[] args) {
    XFile xf = new XFile("nfs://192.168.1.10/nfs-share");

    nfsXFileExtensionAccessor nfsx =
        (nfsXFileExtensionAccessor)xf.getExtensionAccessor();

        if (! nfsx.loginPCNFSD("192.168.1.10", "rpx-nfs-user", "Test123!")) {
             System.out.println("login failed");
             return;
        }

        if (xf.canRead())
             System.out.println("Read permission OK");
        else
             System.out.println("No Read permission");

}

nfs-client-java

Trying to initialize Nfs3 object with "nfs-client-java" I get a MountException that looks like:

com.emc.ecs.nfsclient.mount.MountException: mount failure, 
    server: 192.168.1.205, 
    export: /home/share, 
    nfs version: 3, 
    returned state: 13
at com.emc.ecs.nfsclient.nfs.nfs3.Nfs3.lookupRootHandle(Nfs3.java:359)

State 13 on this point says Permission denied.


I can access this share from another CentOS-System (with authorized to access to this folder uid and gid) by mounting this share and from Windows-System(with authorized to access to this folder login and password) as well.

Is there anyone, who has already solved this problem? Or maybe someone can help me get further?


Solution

  • The problem was solved by enabling CIFS protokol on the share and using old implimentation with JCIFS to transfer the data.