I am trying to access a folder on my local computer using an smb URL. my project is using the jars: commons-vfs2-2.0.jar and jcifs-1.3.17.jar (and all the other required jars). The code in it's entirety is:
public static void main(String[] args) throws FileSystemException {
jcifs.Config.registerSmbURLHandler();
StaticUserAuthenticator auth = new StaticUserAuthenticator(<domain>,<user>,<password>);
FileSystemOptions opts = new FileSystemOptions();
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
FileSystemManager fs = VFS.getManager();
FileObject smbFile = fs.resolveFile("smb://10.0.2.2/TimeOut/");
System.out.println(smbFile.exists() + " " + smbFile.getContent().getLastModifiedTime());
}
I am receiving the exception:
Exception in thread "main" org.apache.commons.vfs2.FileSystemException: Could not determine the type of file "smb://10.0.2.2/TimeOut". at org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:505) at org.apache.commons.vfs2.provider.AbstractFileObject.exists(AbstractFileObject.java:477) at com.newsway.tests.VfsTest.main(VfsTest.java:23) Caused by: jcifs.smb.SmbAuthException: Logon failure: account currently disabled. at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:546) at jcifs.smb.SmbTransport.send(SmbTransport.java:663) at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:390) at jcifs.smb.SmbSession.send(SmbSession.java:218) at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176) at jcifs.smb.SmbFile.doConnect(SmbFile.java:911) at jcifs.smb.SmbFile.connect(SmbFile.java:954) at jcifs.smb.SmbFile.connect0(SmbFile.java:880) at jcifs.smb.SmbFile.open0(SmbFile.java:972) at jcifs.smb.SmbFile.open(SmbFile.java:1006) at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:73) at jcifs.smb.SmbFileInputStream.(SmbFileInputStream.java:65) at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844) at org.apache.commons.vfs2.provider.url.UrlFileObject.doGetType(UrlFileObject.java:89) at org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:496)
from which I understand that the relevant part is: Logon failure: account currently disabled.
This is despite the fact that my user/password/domain are fine and I am doing exactly what is defined in the VFS documentation page.
What am I missing?
jcifs.Config.registerSmbURLHandler();
looks wrong. It seems it uses the URL handler instead of the jcifs provider. Can you addSystem.out.println("prov? " + fs.hasProvider("smb"));
after getManager()? – eckes