flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Smith <java.dev....@gmail.com>
Subject Problem trying to read resource files.
Date Mon, 06 May 2019 15:26:31 GMT
Hi, using Flink 1.8.0 and I have a Gradle project created using the cli
util.

When running inside the IDE the below works perfectly fine...

ClassLoader classLoader = ClassLoader.getSystemClassLoader();
System.out.println("Config: " +
classLoader.getResource(fileName).getFile());

But when Submitting the job using ./flink run my-fat.jar. It doesn't work.
I checked the jar and the file is in the root of the jar, but not in the
classpath.

I have also attempted to print the content of the classpath using the below
code. In the IDE the file show up in the classpath, once it is submitted as
a job it does not appear.

    public static Collection<String> getResources(
        final Pattern pattern){
        final ArrayList<String> retval = new ArrayList<String>();
        final String classPath = System.getProperty("java.class.path", ".");
        final String[] classPathElements =
classPath.split(System.getProperty("path.separator"));
        for(final String element : classPathElements){
            retval.addAll(getResources(element, pattern));
        }
        return retval;
    }

Mime
View raw message