commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Fortner <phidia...@gmail.com>
Subject [vfs] Interpreting "~" in VFS and minimum set of JARs
Date Mon, 31 Dec 2012 18:21:53 GMT
I was wondering if the tilde symbol is going to be interpreted properly, so
I wrote the following Groovy snippet to try and answer that question.  But
I kept tripping over an exception which seems to be due to me not including
the right dependencies.

I used the dependencies listed in the  documentation, but given the error
seems to be with loading the DefaultLocalFileProvider, I find myself
wondering what the minimal set of dependencies are for local file
resolution.  I would think that the first six dependencies should be
sufficient to resolve any local file.  What am I missing?

@Grapes([
    @Grab(group='org.apache.commons', module='commons-vfs2', version='2.0'),
    @Grab(group='commons-logging', module='commons-logging',
version='1.1.1'),
    @Grab(group='commons-net', module='commons-net', version='3.2'),
    @Grab(group='commons-collections', module='commons-collections',
version='3.2.1'),
    @Grab(group='ant', module='ant', version='1.7.0'),
    @Grab(group='org.apache.commons', module='commons-compress',
version='1.4.1'),

@Grab(group='commons-httpclient', module='commons-httpclient',
version='3.1'),
    @Grab(group='com.jcraft', module='jsch', version='0.1.49')

])
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.VFS;


FileObject file = VFS.getManager().resolve("~");
println file;

And got the following stack trace back:

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 org.apache.commons.vfs2.VFS$getManager.call(Unknown Source)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at ConsoleScript17.run(ConsoleScript17:17)
at
groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:266)
at groovy.lang.GroovyShell.run(GroovyShell.java:517)
at groovy.lang.GroovyShell.run(GroovyShell.java:172)
at groovy.lang.GroovyShell$run.call(Unknown Source)
at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy:927)
at sun.reflect.GeneratedMethodAccessor283.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884)
at
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy)
at sun.reflect.GeneratedMethodAccessor282.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884)
at groovy.lang.Closure.call(Closure.java:412)
at groovy.lang.Closure.call(Closure.java:406)
at groovy.lang.Closure.run(Closure.java:490)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.commons.vfs2.FileSystemException: Could not load VFS
configuration from
"jar:file:/Users/markfortner/.groovy/grapes/org.apache.commons/commons-vfs2/jars/commons-vfs2-2.0.jar!/org/apache/commons/vfs2/impl/providers.xml".
at
org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:199)
at
org.apache.commons.vfs2.impl.StandardFileSystemManager.init(StandardFileSystemManager.java:123)
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:601)
at org.apache.commons.vfs2.VFS.createManager(VFS.java:88)
... 32 more
Caused by: org.apache.commons.vfs2.FileSystemException: Could not create
file provider of class
"org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider".
at
org.apache.commons.vfs2.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:490)
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)
... 38 more
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:128)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at
org.apache.commons.vfs2.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:485)
... 41 more

Cheers,

Mark

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message