java-bigchaindb-driver
java-bigchaindb-driver copied to clipboard
Driver incompatibility problems with spring-boot
I've got a spring-boot:1.5.3.RELEASE project.
I was using spring-boot-starter-test.
It has the following dependencies:
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.8.RELEASE:compile
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:compile
[INFO] | | \- net.minidev:json-smart:jar:2.2.1:compile
[INFO] | | \- net.minidev:accessors-smart:jar:1.1:compile
[INFO] | | \- org.ow2.asm:asm:jar:5.0.3:compile
[INFO] | +- junit:junit:jar:4.12:compile
[INFO] | +- org.assertj:assertj-core:jar:2.6.0:compile
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:compile
[INFO] | | \- org.objenesis:objenesis:jar:2.1:runtime
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:compile
[INFO] | +- org.skyscreamer:jsonassert:jar:1.4.0:compile
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:compile
Unfortunately the org.json.JSONObject from com.vaadin.external.google:android-json dependency (see screenshot below) conflicts with org.json.JSONObjectfrom org.json:json
This conflict is causing the following exception initially:
java.lang.NoSuchFieldException: map
at java.lang.Class.getDeclaredField(Class.java:2070)
at com.authenteq.util.DriverUtils.makeSelfSorting(DriverUtils.java:79)
at com.authenteq.builders.BigchainDbTransactionBuilder$Builder.sign(BigchainDbTransactionBuilder.java:304)
at com.authenteq.builders.BigchainDbTransactionBuilder$Builder.buildAndSign(BigchainDbTransactionBuilder.java:323)
and later on
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[na:1.8.0_101]
at java.util.ArrayList.get(ArrayList.java:429) ~[na:1.8.0_101]
at com.authenteq.builders.BigchainDbTransactionBuilder$Builder.sign(BigchainDbTransactionBuilder.java:310) ~[java-bigchaindb-driver-0.1.jar:na]
at com.authenteq.builders.BigchainDbTransactionBuilder$Builder.buildAndSign(BigchainDbTransactionBuilder.java:323) ~[java-bigchaindb-driver-0.1.jar:na]
We should consider addressing this. What do you think?
One of the possible workarounds/solutions for this would be to modify the pom.xml to exclude that dependency (not very nice).
<exclusions>
<exclusion>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
</exclusion>
</exclusions>
Let me review this. I have yet to fully test the driver on an Android Project. I'll check this out and update this issue.
This is one of the toughest design decisions I had to make during initial driver creation. The JSON itself has to be sorted by key desc for the hashing to work properly on the final result. We probably have to drop org.json from the project completely and replace it with something that does sorting by key natively.