damiencarol / jsr203-hadoop

A Java NIO file system provider for HDFS
https://github.com/damiencarol/jsr203-hadoop
Apache License 2.0
56 stars 37 forks source link

how to use the lib in tomcat ? #29

Closed renyaoxiang closed 6 years ago

renyaoxiang commented 7 years ago

we want to use the jsr203 lib in tomcat, but found it unuseable , the classes of the lib can not be loaded by the jvm classloader. while we use the schema like hdfs://somefile, it was be handled by the default FileSystem class. how to fix the problem?

damiencarol commented 7 years ago

What is the pb? Could you provide a stack trace? How did you package it? You need to have some Hadoop jar in the path (Hadoop jars are not included)

renyaoxiang commented 7 years ago

I want to make sure if it is a valid usage of using the lib in tomcat . it makes no error and has no effect I found the source in jdk, it looks like that the fileSystemProvider can be loaded only once, so it can not be configed dynamicly. is it right? so while the tomcat has be started, the jsr203 loaded by tomcat class loader . but can not be found by jvm. is it right?

jdk1.8 FileSystemProvider.java line:153 `
// loads all installed providers private static List loadInstalledProviders() { List list = new ArrayList();

    ServiceLoader<FileSystemProvider> sl = ServiceLoader
        .load(FileSystemProvider.class, ClassLoader.getSystemClassLoader());

    // ServiceConfigurationError may be throw here
    for (FileSystemProvider provider: sl) {
        String scheme = provider.getScheme();

        // add to list if the provider is not "file" and isn't a duplicate
        if (!scheme.equalsIgnoreCase("file")) {
            boolean found = false;
            for (FileSystemProvider p: list) {
                if (p.getScheme().equalsIgnoreCase(scheme)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                list.add(provider);
            }
        }
    }
    return list;
}

`

renyaoxiang commented 6 years ago

@damiencarol Thank you!