java - 在Apache Spark上运行JPMML时出现UnmarshalException

标签 java maven apache-spark hadoop pmml

我正在尝试在Apache Spark 2.0.1上运行使用JPPML版本1.4.1的代码。 pom文件的相关部分如下:

....

<dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.11</artifactId>
      <version>2.0.1</version>
</dependency>

....

<dependency>
    <groupId>org.jpmml</groupId>
    <artifactId>pmml-evaluator</artifactId>
    <version>1.4.1</version>
</dependency>
<dependency>
    <groupId>org.jpmml</groupId>
    <artifactId>pmml-evaluator-extension</artifactId>
    <version>1.4.1</version>
</dependency>
<dependency>
    <groupId>org.jpmml</groupId>
    <artifactId>pmml-model</artifactId>
    <version>1.4.1</version>
</dependency>

但是,我得到UnmarshalException:
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.dmg.org/PMML-4_3", local:"PMML"). Expected elements are <{http://www.dmg.org/PMML-4_2}ARIMA>,<{http://www.dmg.org/PMML-4_2}Aggregate>,<{http://www.dmg.org/PMML-4_2}Alternate>,<{http://www.dmg.org/PMML-4_2}Annotation>,<{http://www.dmg.org/PMML-4_2}Anova>,<{http://www.dmg.org/PMML-4_2}AnovaRow>,<{http://www.dmg.org/PMML-4_2}AntecedentSequence>,<{http://www.dmg.org/PMML-4_2}AnyDistribution>,<{http://www.dmg.org/PMML-4_2}Application>,<{http://www.dmg.org/PMML-4_2}Apply>,<{http://www.dmg.org/PMML-4_2}Array>,<{http://www.dmg.org/PMML-4_2}AssociationModel>,<{http://www.dmg.org/PMML-4_2}AssociationRule>,<{http://www.dmg.org/PMML-4_2}Attribute>,<{http://www.dmg.org/PMML-4_2}BaseCumHazardTables>,<{http://www.dmg.org/PMML-4_2}Baseline>,<{http://www.dmg.org/PMML-4_2}BaselineCell>,<{http://www.dmg.org/PMML-4_2}BaselineModel>,<{http://www.dmg.org/PMML-4_2}BaselineStratum>,<{http://www.dmg.org/PMML-4_2}BayesInput>,<{http://www.dmg.org/PMML-4_2}BayesInputs>,<{http://www.dmg.org/PMML-4_2}BayesOutput>,<{http://www.dmg.org/PMML-4_2}BoundaryValueMeans>,<{http://www.dmg.org/PMML-4_2}BoundaryValues>,<{http://www.dmg.org/PMML-4_2}CategoricalPredictor>,<{http://www.dmg.org/PMML-4_2}Categories>,<{http://www.dmg.org/PMML-4_2}Category>,<{http://www.dmg.org/PMML-4_2}CenterFields>,<{http://www.dmg.org/PMML-4_2}Characteristic>,<{http://www.dmg.org/PMML-4_2}Characteristics>,<{http://www.dmg.org/PMML-4_2}ChildParent>,<{http://www.dmg.org/PMML-4_2}ClassLabels>,<{http://www.dmg.org/PMML-4_2}Cluster>,<{http://www.dmg.org/PMML-4_2}ClusteringField>,<{http://www.dmg.org/PMML-4_2}ClusteringModel>,<{http://www.dmg.org/PMML-4_2}ClusteringModelQuality>,<{http://www.dmg.org/PMML-4_2}Coefficient>,<{http://www.dmg.org/PMML-4_2}Coefficients>,<{http://www.dmg.org/PMML-4_2}ComparisonMeasure>,<{http://www.dmg.org/PMML-4_2}Comparisons>,<{http://www.dmg.org/PMML-4_2}ComplexPartialScore>,<{http://www.dmg.org/PMML-4_2}CompoundPredicate>,<{http://www.dmg.org/PMML-4_2}CompoundRule>,<{http://www.dmg.org/PMML-4_2}Con>,<{http://www.dmg.org/PMML-4_2}ConfusionMatrix>,<{http://www.dmg.org/PMML-4_2}ConsequentSequence>,<{http://www.dmg.org/PMML-4_2}Constant>,<{http://www.dmg.org/PMML-4_2}Constraints>,<{http://www.dmg.org/PMML-4_2}ContStats>,<{http://www.dmg.org/PMML-4_2}CorrelationFields>,<{http://www.dmg.org/PMML-4_2}CorrelationMethods>,<{http://www.dmg.org/PMML-4_2}CorrelationValues>,<{http://www.dmg.org/PMML-4_2}Correlations>,<{http://www.dmg.org/PMML-4_2}CountTable>,<{http://www.dmg.org/PMML-4_2}Counts>,<{http://www.dmg.org/PMML-4_2}Covariances>,<{http://www.dmg.org/PMML-4_2}CovariateList>,<{http://www.dmg.org/PMML-4_2}DataDictionary>,<{http://www.dmg.org/PMML-4_2}DataField>,<{http://www.dmg.org/PMML-4_2}Decision>,<{http://www.dmg.org/PMML-4_2}DecisionTree>,<{http://www.dmg.org/PMML-4_2}Decisions>,<{http://www.dmg.org/PMML-4_2}DefineFunction>,<{http://www.dmg.org/PMML-4_2}Delimiter>,<{http://www.dmg.org/PMML-4_2}DerivedField>,<{http://www.dmg.org/PMML-4_2}DiscrStats>,<{http://www.dmg.org/PMML-4_2}Discretize>,<{http://www.dmg.org/PMML-4_2}DiscretizeBin>,<{http://www.dmg.org/PMML-4_2}DocumentTermMatrix>,<{http://www.dmg.org/PMML-4_2}EventValues>,<{http://www.dmg.org/PMML-4_2}ExponentialSmoothing>,<{http://www.dmg.org/PMML-4_2}Extension>,<{http://www.dmg.org/PMML-4_2}FactorList>,<{http://www.dmg.org/PMML-4_2}False>,<{http://www.dmg.org/PMML-4_2}FieldColumnPair>,<{http://www.dmg.org/PMML-4_2}FieldRef>,<{http://www.dmg.org/PMML-4_2}FieldValue>,<{http://www.dmg.org/PMML-4_2}FieldValueCount>,<{http://www.dmg.org/PMML-4_2}GaussianDistribution>,<{http://www.dmg.org/PMML-4_2}GeneralRegressionModel>,<{http://www.dmg.org/PMML-4_2}Header>,<{http://www.dmg.org/PMML-4_2}INT-Entries>,<{http://www.dmg.org/PMML-4_2}INT-SparseArray>,<{http://www.dmg.org/PMML-4_2}Indices>,<{http://www.dmg.org/PMML-4_2}InlineTable>,<{http://www.dmg.org/PMML-4_2}InstanceField>,<{http://www.dmg.org/PMML-4_2}InstanceFields>,<{http://www.dmg.org/PMML-4_2}Interval>,<{http://www.dmg.org/PMML-4_2}Item>,<{http://www.dmg.org/PMML-4_2}ItemRef>,<{http://www.dmg.org/PMML-4_2}Itemset>,<{http://www.dmg.org/PMML-4_2}KNNInput>,<{http://www.dmg.org/PMML-4_2}KNNInputs>,<{http://www.dmg.org/PMML-4_2}KohonenMap>,<{http://www.dmg.org/PMML-4_2}Level>,<{http://www.dmg.org/PMML-4_2}LiftData>,<{http://www.dmg.org/PMML-4_2}LiftGraph>,<{http://www.dmg.org/PMML-4_2}LinearNorm>,<{http://www.dmg.org/PMML-4_2}LocalTransformations>,<{http://www.dmg.org/PMML-4_2}MapValues>,<{http://www.dmg.org/PMML-4_2}MatCell>,<{http://www.dmg.org/PMML-4_2}Matrix>,<{http://www.dmg.org/PMML-4_2}MiningBuildTask>,<{http://www.dmg.org/PMML-4_2}MiningField>,<{http://www.dmg.org/PMML-4_2}MiningModel>,<{http://www.dmg.org/PMML-4_2}MiningSchema>,<{http://www.dmg.org/PMML-4_2}MissingValueWeights>,<{http://www.dmg.org/PMML-4_2}ModelExplanation>,<{http://www.dmg.org/PMML-4_2}ModelLiftGraph>,<{http://www.dmg.org/PMML-4_2}ModelStats>,<{http://www.dmg.org/PMML-4_2}ModelVerification>,<{http://www.dmg.org/PMML-4_2}MultivariateStat>,<{http://www.dmg.org/PMML-4_2}MultivariateStats>,<{http://www.dmg.org/PMML-4_2}NaiveBayesModel>,<{http://www.dmg.org/PMML-4_2}NearestNeighborModel>,<{http://www.dmg.org/PMML-4_2}NeuralInput>,<{http://www.dmg.org/PMML-4_2}NeuralInputs>,<{http://www.dmg.org/PMML-4_2}NeuralLayer>,<{http://www.dmg.org/PMML-4_2}NeuralNetwork>,<{http://www.dmg.org/PMML-4_2}NeuralOutput>,<{http://www.dmg.org/PMML-4_2}NeuralOutputs>,<{http://www.dmg.org/PMML-4_2}Neuron>,<{http://www.dmg.org/PMML-4_2}Node>,<{http://www.dmg.org/PMML-4_2}NormContinuous>,<{http://www.dmg.org/PMML-4_2}NormDiscrete>,<{http://www.dmg.org/PMML-4_2}NormalizedCountTable>,<{http://www.dmg.org/PMML-4_2}NumericInfo>,<{http://www.dmg.org/PMML-4_2}NumericPredictor>,<{http://www.dmg.org/PMML-4_2}OptimumLiftGraph>,<{http://www.dmg.org/PMML-4_2}Output>,<{http://www.dmg.org/PMML-4_2}OutputField>,<{http://www.dmg.org/PMML-4_2}PCell>,<{http://www.dmg.org/PMML-4_2}PCovCell>,<{http://www.dmg.org/PMML-4_2}PCovMatrix>,<{http://www.dmg.org/PMML-4_2}PMML>,<{http://www.dmg.org/PMML-4_2}PPCell>,<{http://www.dmg.org/PMML-4_2}PPMatrix>,<{http://www.dmg.org/PMML-4_2}PairCounts>,<{http://www.dmg.org/PMML-4_2}ParamMatrix>,<{http://www.dmg.org/PMML-4_2}Parameter>,<{http://www.dmg.org/PMML-4_2}ParameterField>,<{http://www.dmg.org/PMML-4_2}ParameterList>,<{http://www.dmg.org/PMML-4_2}Partition>,<{http://www.dmg.org/PMML-4_2}PartitionFieldStats>,<{http://www.dmg.org/PMML-4_2}PoissonDistribution>,<{http://www.dmg.org/PMML-4_2}PredictiveModelQuality>,<{http://www.dmg.org/PMML-4_2}Predictor>,<{http://www.dmg.org/PMML-4_2}PredictorTerm>,<{http://www.dmg.org/PMML-4_2}Quantile>,<{http://www.dmg.org/PMML-4_2}REAL-Entries>,<{http://www.dmg.org/PMML-4_2}REAL-SparseArray>,<{http://www.dmg.org/PMML-4_2}ROC>,<{http://www.dmg.org/PMML-4_2}ROCGraph>,<{http://www.dmg.org/PMML-4_2}RandomLiftGraph>,<{http://www.dmg.org/PMML-4_2}Regression>,<{http://www.dmg.org/PMML-4_2}RegressionModel>,<{http://www.dmg.org/PMML-4_2}RegressionTable>,<{http://www.dmg.org/PMML-4_2}ResultField>,<{http://www.dmg.org/PMML-4_2}RuleSelectionMethod>,<{http://www.dmg.org/PMML-4_2}RuleSet>,<{http://www.dmg.org/PMML-4_2}RuleSetModel>,<{http://www.dmg.org/PMML-4_2}ScoreDistribution>,<{http://www.dmg.org/PMML-4_2}Scorecard>,<{http://www.dmg.org/PMML-4_2}SeasonalTrendDecomposition>,<{http://www.dmg.org/PMML-4_2}Seasonality_ExpoSmooth>,<{http://www.dmg.org/PMML-4_2}Segment>,<{http://www.dmg.org/PMML-4_2}Segmentation>,<{http://www.dmg.org/PMML-4_2}Sequence>,<{http://www.dmg.org/PMML-4_2}SequenceModel>,<{http://www.dmg.org/PMML-4_2}SequenceReference>,<{http://www.dmg.org/PMML-4_2}SequenceRule>,<{http://www.dmg.org/PMML-4_2}SetPredicate>,<{http://www.dmg.org/PMML-4_2}SetReference>,<{http://www.dmg.org/PMML-4_2}SimplePredicate>,<{http://www.dmg.org/PMML-4_2}SimpleRule>,<{http://www.dmg.org/PMML-4_2}SimpleSetPredicate>,<{http://www.dmg.org/PMML-4_2}SpectralAnalysis>,<{http://www.dmg.org/PMML-4_2}SupportVector>,<{http://www.dmg.org/PMML-4_2}SupportVectorMachine>,<{http://www.dmg.org/PMML-4_2}SupportVectorMachineModel>,<{http://www.dmg.org/PMML-4_2}SupportVectors>,<{http://www.dmg.org/PMML-4_2}TableLocator>,<{http://www.dmg.org/PMML-4_2}Target>,<{http://www.dmg.org/PMML-4_2}TargetValue>,<{http://www.dmg.org/PMML-4_2}TargetValueCount>,<{http://www.dmg.org/PMML-4_2}TargetValueCounts>,<{http://www.dmg.org/PMML-4_2}TargetValueStat>,<{http://www.dmg.org/PMML-4_2}TargetValueStats>,<{http://www.dmg.org/PMML-4_2}Targets>,<{http://www.dmg.org/PMML-4_2}Taxonomy>,<{http://www.dmg.org/PMML-4_2}TestDistributions>,<{http://www.dmg.org/PMML-4_2}TextCorpus>,<{http://www.dmg.org/PMML-4_2}TextDictionary>,<{http://www.dmg.org/PMML-4_2}TextDocument>,<{http://www.dmg.org/PMML-4_2}TextIndex>,<{http://www.dmg.org/PMML-4_2}TextIndexNormalization>,<{http://www.dmg.org/PMML-4_2}TextModel>,<{http://www.dmg.org/PMML-4_2}TextModelNormalization>,<{http://www.dmg.org/PMML-4_2}TextModelSimiliarity>,<{http://www.dmg.org/PMML-4_2}Time>,<{http://www.dmg.org/PMML-4_2}TimeAnchor>,<{http://www.dmg.org/PMML-4_2}TimeCycle>,<{http://www.dmg.org/PMML-4_2}TimeException>,<{http://www.dmg.org/PMML-4_2}TimeSeries>,<{http://www.dmg.org/PMML-4_2}TimeSeriesModel>,<{http://www.dmg.org/PMML-4_2}TimeValue>,<{http://www.dmg.org/PMML-4_2}Timestamp>,<{http://www.dmg.org/PMML-4_2}TrainingInstances>,<{http://www.dmg.org/PMML-4_2}TransformationDictionary>,<{http://www.dmg.org/PMML-4_2}TreeModel>,<{http://www.dmg.org/PMML-4_2}True>,<{http://www.dmg.org/PMML-4_2}UniformDistribution>,<{http://www.dmg.org/PMML-4_2}UnivariateStats>,<{http://www.dmg.org/PMML-4_2}Value>,<{http://www.dmg.org/PMML-4_2}VectorDictionary>,<{http://www.dmg.org/PMML-4_2}VectorFields>,<{http://www.dmg.org/PMML-4_2}VectorInstance>,<{http://www.dmg.org/PMML-4_2}VerificationField>,<{http://www.dmg.org/PMML-4_2}VerificationFields>,<{http://www.dmg.org/PMML-4_2}XCoordinates>,<{http://www.dmg.org/PMML-4_2}YCoordinates>,<{http://www.dmg.org/PMML-4_2}binarySimilarity>,<{http://www.dmg.org/PMML-4_2}chebychev>,<{http://www.dmg.org/PMML-4_2}cityBlock>,<{http://www.dmg.org/PMML-4_2}euclidean>,<{http://www.dmg.org/PMML-4_2}jaccard>,<{http://www.dmg.org/PMML-4_2}minkowski>,<{http://www.dmg.org/PMML-4_2}row>,<{http://www.dmg.org/PMML-4_2}simpleMatching>,<{http://www.dmg.org/PMML-4_2}squaredEuclidean>,<{http://www.dmg.org/PMML-4_2}tanimoto>
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:647)
    at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:258)
    at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:253)
    at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:120)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1052)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:483)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:464)
    at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:152)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at org.jpmml.model.filters.PMMLFilter.startElement(PMMLFilter.java:69)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:216)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:189)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:140)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:123)
    at org.jpmml.model.JAXBUtil.unmarshal(JAXBUtil.java:78)
    at org.jpmml.model.JAXBUtil.unmarshalPMML(JAXBUtil.java:64)
    at org.jpmml.model.PMMLUtil.unmarshal(PMMLUtil.java:35)
    at test.readPMML(ConfidencePredictor.java:187)
   ....

现在,JPMML-SparkML依赖于JPMML-Model库的最新和最大版本,该版本与Apache Spark发行版中的旧版冲突。该冲突记录在SPARK-15526中。

我尝试着色并删除了pmml-schema-1.2.15.jar和pmml-model-1.2.15.jar文件,但没有任何效果。

如何解决?

最佳答案

实际上,我通过删除Spark的jars文件夹中的pmml-schema-1.2.15.jarpmml-model-1.2.15.jar来解决此问题。它不起作用的原因是因为我删除了群集中Spark文件夹中的文件,但没有删除本地Spark文件夹中的文件(需要同时删除这两个文件)。

关于java - 在Apache Spark上运行JPMML时出现UnmarshalException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52758358/

相关文章:

java - POM.xml 中的 tomcat 资源错误

maven - Gradle 不会将系统属性传递给测试类

java - Spark Streaming/Spark 在 main() 方法中是否像 while 循环一样工作?

java - 使用maven构建geoserver(monitor-hibernate)

不支持 java.util.Date

hadoop - 如何使用Spark生成和输出多个Java对象?

java - 如何使用 SL4J 将变量包装在 Log4j2 上

java - 可分发库中的SLF4J,如何获取Logger

java - eclipse中打包可执行jar文件报错

java - 什么会导致bash无法执行在我自己的机器上编写和编译的.jar?