1

I want to use a library (JAI) with spark to parse some spatial raster files. Unfortunately, there are some strange issues. JAI only works when running via the build tool i.e. sbt run when executed in spark.

When executed via spark-submit the error is:

java.lang.IllegalArgumentException: The input argument(s) may not be null.
    at javax.media.jai.ParameterBlockJAI.getDefaultMode(ParameterBlockJAI.java:136)
    at javax.media.jai.ParameterBlockJAI.<init>(ParameterBlockJAI.java:157)
    at javax.media.jai.ParameterBlockJAI.<init>(ParameterBlockJAI.java:178)
    at org.geotools.process.raster.PolygonExtractionProcess.execute(PolygonExtractionProcess.java:171)

Which looks like some native dependency is not called correctly.

Assuming something is wrong with the class path I tried to run a plain java/scala function. but this one works just fine. In fact, the exact same problem occurs when Nifi is calling the parse function.

Is spark messing with the class paths? What is different from running the jar natively via java-jar or through spark or NiFi? Both show the same problem even when concurrency is disabled and they run only on a single thread. JAI vendorname == null is somewhat similar as it shows what can go wrong when running a jar with JAI. I could not identify this as the exact same problem though.

I created a minimal example here: https://github.com/geoHeil/jai-packaging-problem Due to the dependency on the build process & packaging of native libraries I think it will not be possible to include snippets directly in this posting.

edit

I am pretty convinced this has to do the the assembly merge strategy, so far I could not find one which works.

Below you can see that the Vectorize operation is missing on sparks class path Vectorize is missing and returning null

edit 2

I think spark / NiFis class loader will not load some of the required registry files for JAI. A plain java app works fine with these assembly/ fat-jar settings.

Georg Heiler
  • 16,916
  • 36
  • 162
  • 292

0 Answers0