0

我尝试使用库 smbj 连接文件服务器,我收到错误“无法加载类“org.slf4j.impl.StaticLoggerBinder”。” 共享错误日志以供参考。我的要求是将“jcifs library”更改为“smbj library”,为此编写了以下示例代码。

CODE:-
import com.hierynomus.msfscc.fileinformation.FileIdBothDirectoryInformation;
import com.hierynomus.smbj.SMBClient;
import com.hierynomus.smbj.auth.AuthenticationContext;
import com.hierynomus.smbj.connection.Connection;
import com.hierynomus.smbj.session.Session;
import com.hierynomus.smbj.share.DiskShare;
import net.engio.mbassy.bus.error.IPublicationErrorHandler;
import net.engio.mbassy.bus.error.PublicationError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

    public class pseudo {
        public static void main(String[] args) throws Exception {
    
        @SuppressWarnings("resource")
        SMBClient client = new SMBClient();
    
        try (Connection connection = client.connect("xxxxx")) {
            AuthenticationContext ac = new AuthenticationContext("xxxx", "xxxx".toCharArray(), "DOMAIN");
            Session session = connection.authenticate(ac);
    
            // Connect to Share
            try (DiskShare share = (DiskShare) session.connectShare("XXXX\")) {
                for (FileIdBothDirectoryInformation f : share.list("")) {
                    System.out.println("File : " + f.getFileName());
                }           
            }
        }
    }  
    }

错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: net/engio/mbassy/bus/error/IPublicationErrorHandler
    at com.hierynomus.smbj.SMBClient.<init>(SMBClient.java:54)
    at com.hierynomus.smbj.SMBClient.<init>(SMBClient.java:50)
    at com.tnq.fms.poc2.main(poc2.java:23)
Caused by: java.lang.ClassNotFoundException: net.engio.mbassy.bus.error.IPublicationErrorHandler
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 3 more

使用的库: smbj-0.11.3.jar slf4j-api-1.7.15.jar log4j-1.2.16.jar

4

0 回答 0