Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot update pmml-android from 1.3.6 to 1.4.15 due to jackson dependency #23

Closed
jamesweb1 opened this issue Feb 19, 2020 · 4 comments
Closed

Comments

@jamesweb1
Copy link

I try to update pmml-android from 1.3.6 to 1.4.15. But it cannot run mvn clean install successfully. It shows the following errors:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for JPMML-Android 1.0-SNAPSHOT:
[INFO] 
[INFO] JPMML-Android ...................................... SUCCESS [  0.158 s]
[INFO] pmml-android ....................................... SUCCESS [  3.407 s]
[INFO] pmml-android-example ............................... FAILURE [01:19 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:24 min
[INFO] Finished at: 2020-02-19T18:09:49+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jpmml:pmml-maven-plugin:1.4.15:ser (default) on project pmml-android-example: Execution default of goal org.jpmml:pmml-maven-plugin:1.4.15:ser failed: Plugin org.jpmml:pmml-maven-plugin:1.4.15 or one of its dependencies could not be resolved: Failed to collect dependencies at org.jpmml:pmml-maven-plugin:jar:1.4.15 -> org.jpmml:pmml-model-jackson:jar:1.4.15 -> com.fasterxml.jackson.core:jackson-databind:jar:2.9.0,pr4-SNAPSHOT: Failed to read artifact descriptor for com.fasterxml.jackson.core:jackson-databind:jar:2.9.0,pr4-SNAPSHOT: Could not find artifact com.fasterxml.jackson:jackson-bom:pom:2.9.0.pr4-SNAPSHOT in sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :pmml-android-example

How can I solve this issue?

@vruusmann
Copy link
Member

vruusmann commented Feb 19, 2020

The JPMML-Android project is obsolete today, because you can distribute PMML models in the JSON data format (instead of the default XML data format), or transpile them to 100% Java bytecode using the JPMML-Transpiler library.

I really should do a technical post about it one day.

How can I solve this issue?

Identify which JPMML library is bringing in the Jackson transitive dependency (eg. using mvn dependency:tree), and then add the following exclusion:

<dependency>
  <groupId>..</groupId>
  <artifactId>..</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.jpmml</groupId>
      <artifactId>pmml-model-jackson</artifactId>
    </exclusion>
  </exclusions>
</dependency>

@vruusmann
Copy link
Member

Failed to read artifact descriptor for com.fasterxml.jackson.core:jackson-databind:jar:2.9.0,pr4-SNAPSHOT

I ran into exactly the same issue today, when pushing out new commits to the 1.5-SNAPSHOT development branch:
https://travis-ci.org/jpmml/jpmml-model/builds/652544379

Turns out that some Maven repositories contain an incomplete Jackson 2.9.0.pr4-SNAPSHOT version. The only fix for this is to update the range of Jackson dependency to "2.9.1 or greater", so that this incomplete 2.9.0-pr4 would fall outside of its bounds.

Here's my code change:
c952016

@jamesweb1
Copy link
Author

Thanks your help. I'm trying to use jpmml-transpiler to load the pmml file into my Android App. But I cannot translate it to ModelEvaluator successfully.

Here is the example of my code:

val inputStream = context!!.assets.open("model.pmml")
val xmlPmml = PMMLUtil.unmarshal(inputStream)
val jCodeModel = TranspilerUtil.translate(xmlPmml, "com.example.PMMLModel")
val javaPmml = PMMLUtil.load(jCodeModel.javaClass.classLoader)
clf = ModelEvaluatorBuilder(javaPmml).build()
clf?.verify()

It shows error:

2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err: org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:160)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at org.jpmml.model.SAXUtil.createFilteredSource(SAXUtil.java:35)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at org.jpmml.model.PMMLUtil.unmarshal(PMMLUtil.java:54)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at com.example.pmml.Classifier$Companion.initEventClassifier(Classifier.kt:24)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at com.example.pmm.InitProvider.onCreate(InitProvider.kt:16)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at android.content.ContentProvider.attachInfo(ContentProvider.java:2113)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at android.content.ContentProvider.attachInfo(ContentProvider.java:2087)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at android.app.ActivityThread.installProvider(ActivityThread.java:7364)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at android.app.ActivityThread.access$1400(ActivityThread.java:267)
2020-02-20 10:55:00.984 7810-7810/com.example.pmml W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)
2020-02-20 10:55:00.985 7810-7810/com.example.pmml W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:107)
2020-02-20 10:55:00.985 7810-7810/com.example.pmml W/System.err:     at android.os.Looper.loop(Looper.java:237)
2020-02-20 10:55:00.985 7810-7810/com.example.pmml W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7770)
2020-02-20 10:55:00.985 7810-7810/com.example.pmml W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-02-20 10:55:00.985 7810-7810/com.example.pmml W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
2020-02-20 10:55:00.985 7810-7810/com.example.pmml W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)

I saw the usage in JPMML-Transpiler, and it said loading xmllmml first and then write to file and read from file and using URLClassLoader to load to javaPmml. It seems to be a little complicated for my application. I just want to load model.pmml in the Android device and make the correct ModelEvaluator to predict. What's the best solution for me?

@vruusmann
Copy link
Member

vruusmann commented Feb 20, 2020

In principle, you need to split your workflow into two pieces.

The first three lines must be executed in an environment that provides JAXB functionality (Android doesn't):

val inputStream = context!!.assets.open("model.pmml")
val xmlPmml = PMMLUtil.unmarshal(inputStream)
val jCodeModel = TranspilerUtil.translate(xmlPmml, "com.example.PMMLModel")

Dump the above jCodeModel object into a JAR file, and distribute it instead of the PMML XML file.

The second piece - loading a transpiled org.dmg.pmml.PMML object from the JAR file - should work in any environment as it uses Java/JVM natine class file loading only (ie. there is no XML work involved).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants