Hi Youping,
> Following your suggestion to translate Maven to SBT,
> and added an exclude cause in Dependencies as below:
> "org.jpmml" % "jpmml-sparkml" % "1.1.5" exclude("com.beust", "jcommander"),
>
You've just downgraded from 1.1.7 to 1.1.5. Not a good idea - always
stay with the latest.
The library installation instructions are given here:
https://github.com/jpmml/jpmml-sparkml#installation
Two important things:
1) Exclude org.jpmml:pmml-model dependency that is inherited via
org.apache.spark:spark-mllib_2.1 dependency.
2) And to be extra sure, rename org.dmg.pmml.* and org.jpmml.*
packages (that are inherited via the JPMML-SparkML 1.1.7 library) to
something like com.mycompany.org.dmg.pmml.* and
com.mycompany.org.jpmml.* In Apache Maven, you can rename Java
packages using the Maven Shade plugin. I have no idea how it's done in
SBT.
The above installation instructions are "the one and only way of doing
it right". If you try to cut corners, then you'll be experiencing
classpath conflicts sooner or later.
> Now I see some improvement (I hope). The new exception is as follow:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/spark/ml/regression/GeneralizedLinearRegressionModel
> at org.jpmml.sparkml.ConverterUtil.<clinit>(ConverterUtil.java:323)
>
In previous JPMML-SparkML library versions the list of converter
classes was hardcoded in the static initializer block of the
ConverterUtil class. It was not a very good solution, because if one
converter class could not be found (eg. due to outdated Apache Spark
version), then the whole initialization procedure errored out, and the
PMML conversion functionality became unavailable.
> The strange thing is that my code doesn't use GeneralizedLinearRegression.
> Any idea what this new exception means?
> Thanks again
>
You're trying to use JPMML-SparkML version 1.1.X with Apache Spark
version that doesn't "contain" the GeneralizedLinearRegression class
yet. Must be some 1.6.X version?
JPMML-SparkML 1.1.6 and earlier, which contain hardcoded list of
converter classes, will fail if some class is missing. JPMML-SparkML
1.1.7 and newer, which load converter classes from the
META-INF/sparkml2pmml.properties file, will emit a "class XYZ not
found" warning to log, and keep loading other classes.
VR