2

我正在使用 vfs2(不是 vfs)来访问 ftp。现在我也使用 smb 协议,但它不起作用。我总是得到例外:

ClassNotFoundException: org.apache.commons.vfs.provider.FileProvider

但是当我使用 vfs2 时,它搜索具有 commons.vfs.provider 而不是 commons.vfs2.provider 的类很奇怪 - 因为在 vfs2 中存在该类。

我想念图书馆(罐子)吗?

我现在有:,commons-vfs2-2.0.jar(必须commons-vfs2-sandbox-2.0.jar添加才能找到 smb 协议),,,,,可能还有更多..jcifs-1.3.17.jarcommons-net-3.3.jarcommons-collections-3.2.1.jarcommons-logging-1.1.1.jar

这是我完整的 StackTrace:

org.apache.commons.vfs2.FileSystemException: Could not create a file system manager of class "org.apache.commons.vfs2.impl.StandardFileSystemManager".
    at org.apache.commons.vfs2.VFS.createManager(VFS.java:99)
    at org.apache.commons.vfs2.VFS.getManager(VFS.java:50)
    at com.avintis.framework.service.DbAccessImpl.saveArchiveData(DbAccessImpl.java:1188)
    at com.avintis.framework.service.DbAccessImpl.saveMessageData(DbAccessImpl.java:905)
    at com.avintis.framework.service.DbAccessImpl.saveMessage(DbAccessImpl.java:417)
    at com.avintis.framework.service.ImportTrackingMsgServiceImpl.importFile(ImportTrackingMsgServiceImpl.java:77)
    at com.avintis.framework.service.ImportTrackingMsgServiceImpl.importFile(ImportTrackingMsgServiceImpl.java:30)
    at com.avintis.framework.watcher.service.WatcherServiceImpl.addTrackingMessages(WatcherServiceImpl.java:87)
    at com.avintis.framework.watcher.service.WatcherServiceImpl.watchForFiles(WatcherServiceImpl.java:34)
    at com.avintis.framework.schedule.WatcherJob.executeInternal(WatcherJob.java:30)
    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:534)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/vfs/provider/FileProvider
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at org.apache.commons.vfs2.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:485)
    at org.apache.commons.vfs2.impl.StandardFileSystemManager.addProvider(StandardFileSystemManager.java:371)
    at org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:270)
    at org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:195)
    at org.apache.commons.vfs2.impl.StandardFileSystemManager.configurePlugins(StandardFileSystemManager.java:154)
    at org.apache.commons.vfs2.impl.StandardFileSystemManager.init(StandardFileSystemManager.java:126)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.commons.vfs2.VFS.createManager(VFS.java:88)
    ... 12 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.vfs.provider.FileProvider
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    ... 30 more
4

1 回答 1

2

乍一看,您似乎需要commons-vfs.jarnot ,commons-vfs2-2.0.jar因为其中的包名commons-vfs2-2.0.jaris org.apache.commons.vfs2.provider.jar。但这可能会导致混淆 vfs 和 vfs2 类而无法正常工作。

因此,请确保您已加载以下 jars(仅 vfs2):

  • commons-vfs2-2.0.jar
  • commons-vfs2-sandbox-2.0.jar
  • jcifs-1.3.17.jar
  • 和其他依赖的公共资源(网络、日志记录、...)

然后还添加指向 SmbFileProvider 的正确类的内部vfs-providers.xmlMETA-INF

<provider class-name="org.apache.commons.vfs2.provider.smb.SmbFileProvider">
    <scheme name="smb"/>
    <if-available class-name="jcifs.smb.SmbFile"/>
</provider>
于 2014-09-04T12:05:24.403 回答