commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Fuerstenberg <MFuerstenb...@karmann.com>
Subject Antwort: problem loading file with commons vfs
Date Mon, 12 Jan 2009 13:15:59 GMT
Hi Cyril,

please show us a snippet of your implementation.

it should start like the following:



package de.mf.vfs;

import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.VFS;
import org.apache.log4j.Appender;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;

public final class VFSFileExample {

        public static void main(final String... args) throws 
FileSystemException {

                Appender app1 = new ConsoleAppender(new SimpleLayout());
                Logger logger = Logger.getRootLogger();
                logger.addAppender(app1);

                // Initialize
                FileSystemManager vfsManager;
                vfsManager = VFS.getManager();

                FileSystemOptions fileSystemOptions = new 
FileSystemOptions();

                // Create FileObject
                FileObject srcDir =
                    vfsManager.resolveFile("file://C:/tmp/testfile.txt", 
fileSystemOptions);

                logger.info(srcDir);
        }
}

Could I help you with this code example?














Hello,

I got a pretty frustrating (and probably pretty basic) problem with 
loading
a local file using vfs :-)
- I am using the vfs library indirectly through the mondrian olap server
library (standalone, not on app server) which calls it to load some of its
configuration files
- vfs can't read the config file because it can't load a couple of 
internal
classes (DefaultLocalFileProvider, StandardFileSystemManager)
- this happens because of a NullPointerException when instantiating the 
the
StandardFileSystemManager (please see below for the exception stacktrace)

I checked:
- the uri for the config file should be allright (wrong uri would yield 
some
file- or url-exception, right?)
- I included all the required dependent jars, at least I am not getting 
any
NoClassDefFoundErrors etc. no more

So after checking the jar dependencies and the uri I am actually running 
out
of ideas here :-/
I am running java 1.5 and vfs 1.0 on mac osx leopard and I compile the 
whole
thing with eclipse 3.4.1 ganymede

Does anyone have any experience with those kind of problems?

Thank you very much in advance!




Stacktrace:
...*
Caused by: org.apache.commons.vfs.FileSystemException: Could not create a
file system manager of class
"org.apache.commons.vfs.impl.StandardFileSystemManager".*
    at org.apache.commons.vfs.VFS.createManager(VFS.java:93)
    at org.apache.commons.vfs.VFS.getManager(VFS.java:47)
    at mondrian.rolap.RolapSchema.load(RolapSchema.java:283)
    ... 10 more
*Caused by: org.apache.commons.vfs.FileSystemException: Could not load VFS
configuration from
"jar:file:/Users/cyril/sw/apache/commons-vfs-1.0/commons-vfs-1.0.jar!/org/apache/commons/vfs/impl/providers.xml".
*
    at
org.apache.commons.vfs.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:191)
    at
org.apache.commons.vfs.impl.StandardFileSystemManager.init(StandardFileSystemManager.java:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.commons.vfs.VFS.createManager(VFS.java:82)
    ... 12 more
*Caused by: org.apache.commons.vfs.FileSystemException: Could not create
file provider of class
"org.apache.commons.vfs.provider.local.DefaultLocalFileProvider".*
    at
org.apache.commons.vfs.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:469)
    at
org.apache.commons.vfs.impl.StandardFileSystemManager.addProvider(StandardFileSystemManager.java:350)
    at
org.apache.commons.vfs.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:254)
    at
org.apache.commons.vfs.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:187)
    ... 18 more
*Caused by: java.lang.NullPointerException*
    at
org.apache.commons.vfs.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:464)
    ... 21 more


------------------------

Wilhelm Karmann GmbH
Karmannstraße 1, 49084 Osnabrück, Germany
Telefon +49 541 581-0, Telefax +49 541 581-1900
Handelsregister: Amtsgericht Osnabrück, HRB 1059
Geschäftsführer:
Peter Harbig (Sprecher), Wilhelm Dietrich Karmann, Jochen Voß
Aufsichtsratsvorsitzender: Dr. Jobst Wellensiek

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