Java/Dataflow - Unable to use ClassLoader to detect classpath elements

I think this is a Java 9 specific issue. Beam does not officially support Java 9 yet - see https://issues.apache.org/jira/browse/BEAM-2530 for current progress.

You can try working around this specific issue by specifying the classpath elements via --filesToStage instead (this will bypass the autodetection based on current classloader - which is what's failing). However you may hit other issues.


A workaround that works for me in Java 9 is defining filesToStage programmatically based on the classpath.

Her is an example how you can generate the file set from the class path:

dataflowPipelineOptions.setFilesToStage( 
  Arrays.
    asList(System.getProperty("java.class.path").split(File.pathSeparator)).
    stream().
    map(entry -> new File(entry).toString()).
    collect(Collectors.toList())
)