Closed rsteimen closed 3 years ago
Just tested with https://github.com/XRPLF/xrpl4j-sample and received following exception
C:\Users\RS\.jdks\openjdk-14.0.2\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.1\lib\idea_rt.jar=55207:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.1\bin" -Dfile.encoding=UTF-8 -classpath C:\proj\xrpl4j-sample-main\target\classes;C:\Users\RS\.m2\repository\org\xrpl\xrpl4j-client\2.0.0\xrpl4j-client-2.0.0.jar;C:\Users\RS\.m2\repository\org\xrpl\xrpl4j-binary-codec\2.0.0\xrpl4j-binary-codec-2.0.0.jar;C:\Users\RS\.m2\repository\org\xrpl\xrpl4j-crypto-core\2.0.0\xrpl4j-crypto-core-2.0.0.jar;C:\Users\RS\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.2\jackson-annotations-2.11.2.jar;C:\Users\RS\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.11.2\jackson-core-2.11.2.jar;C:\Users\RS\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.11.2\jackson-databind-2.11.2.jar;C:\Users\RS\.m2\repository\com\google\guava\guava\29.0-jre\guava-29.0-jre.jar;C:\Users\RS\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\RS\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\RS\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\RS\.m2\repository\org\checkerframework\checker-qual\2.11.1\checker-qual-2.11.1.jar;C:\Users\RS\.m2\repository\com\google\errorprone\error_prone_annotations\2.3.4\error_prone_annotations-2.3.4.jar;C:\Users\RS\.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\Users\RS\.m2\repository\com\squareup\okhttp3\okhttp\4.8.1\okhttp-4.8.1.jar;C:\Users\RS\.m2\repository\com\squareup\okio\okio\2.7.0\okio-2.7.0.jar;C:\Users\RS\.m2\repository\org\jetbrains\kotlin\kotlin-stdlib-common\1.3.70\kotlin-stdlib-common-1.3.70.jar;C:\Users\RS\.m2\repository\org\jetbrains\kotlin\kotlin-stdlib\1.3.72\kotlin-stdlib-1.3.72.jar;C:\Users\RS\.m2\repository\org\jetbrains\annotations\13.0\annotations-13.0.jar;C:\Users\RS\.m2\repository\io\github\openfeign\feign-core\11.0\feign-core-11.0.jar;C:\Users\RS\.m2\repository\io\github\openfeign\feign-jackson\11.0\feign-jackson-11.0.jar;C:\Users\RS\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\RS\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\RS\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\RS\.m2\repository\org\xrpl\xrpl4j-address-codec\2.0.0\xrpl4j-address-codec-2.0.0.jar;C:\Users\RS\.m2\repository\org\xrpl\xrpl4j-keypairs\2.0.0\xrpl4j-keypairs-2.0.0.jar;C:\Users\RS\.m2\repository\org\bouncycastle\bcprov-jdk15to18\1.66\bcprov-jdk15to18-1.66.jar;C:\Users\RS\.m2\repository\org\xrpl\xrpl4j-crypto-bouncycastle\2.0.0\xrpl4j-crypto-bouncycastle-2.0.0.jar;C:\Users\RS\.m2\repository\com\github\ben-manes\caffeine\caffeine\2.8.8\caffeine-2.8.8.jar;C:\Users\RS\.m2\repository\org\xrpl\xrpl4j-model\2.0.0\xrpl4j-model-2.0.0.jar;C:\Users\RS\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-guava\2.11.2\jackson-datatype-guava-2.11.2.jar;C:\Users\RS\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.2\jackson-datatype-jdk8-2.11.2.jar;C:\Users\RS\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.2\jackson-datatype-jsr310-2.11.2.jar;C:\Users\RS\.m2\repository\com\ripple\cryptoconditions\crypto-conditions\1.0.4\crypto-conditions-1.0.4.jar;C:\Users\RS\.m2\repository\net\i2p\crypto\eddsa\0.3.0\eddsa-0.3.0.jar;C:\Users\RS\.m2\repository\com\ripple\cryptoconditions\jackson-datatype-cryptoconditions\1.0.4\jackson-datatype-cryptoconditions-1.0.4.jar org.xrpl.xrpl4j.samples.SendXrp
Running the SendXrp sample...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by feign.DefaultMethodHandler (file:/C:/Users/RS/.m2/repository/io/github/openfeign/feign-core/11.0/feign-core-11.0.jar) to field java.lang.invoke.MethodHandles$Lookup.IMPL_LOOKUP
WARNING: Please consider reporting this to the maintainers of feign.DefaultMethodHandler
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Generated a wallet with the following public key: EDE9935A6087039267CD8248F0059B06057CB0C8642CFED5C628D25937ACECC46A
Classic Address: rBLKSfDDKQ26TN2ZZQ5UX5a3xxyopEsz96
Funded the account using the Testnet faucet.
Exception in thread "main" org.xrpl.xrpl4j.client.JsonRpcClientErrorException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.ZonedDateTime` from String "2021-May-29 11:17:31.000000000 UTC": Failed to deserialize java.time.ZonedDateTime: (java.time.format.DateTimeParseException) Text '2021-May-29 11:17:31.000000000 UTC' could not be parsed at index 5
at [Source: (String)"{"ledger":{"accepted":true,"account_hash":"6EA245EC465C5297BCB94DC8FAB9B9FBB382C6C74D0EA40704FED9880B044A6F","close_flags":0,"close_time":675602251,"close_time_human":"2021-May-29 11:17:31.000000000 UTC","close_time_resolution":10,"closed":true,"hash":"D46188330B232EED1305BF68FE7095AAE337F8CF76167B8AFE9A0468C5DE9216","ledger_hash":"D46188330B232EED1305BF68FE7095AAE337F8CF76167B8AFE9A0468C5DE9216","ledger_index":"17915159","parent_close_time":675602250,"parent_hash":"7C2ED475EA8672125FAF7B20A7DAD"[truncated 352 chars]; line: 1, column: 168] (through reference chain: org.xrpl.xrpl4j.model.client.ledger.ImmutableLedgerResult$Json["ledger"]->org.xrpl.xrpl4j.model.ledger.ImmutableLedgerHeader$Json["close_time_human"])
at org.xrpl.xrpl4j.client.JsonRpcClient.send(JsonRpcClient.java:120)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:728)
at feign.DefaultMethodHandler.invoke(DefaultMethodHandler.java:75)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
at com.sun.proxy.$Proxy21.send(Unknown Source)
at org.xrpl.xrpl4j.client.JsonRpcClient.send(JsonRpcClient.java:93)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:728)
at feign.DefaultMethodHandler.invoke(DefaultMethodHandler.java:75)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
at com.sun.proxy.$Proxy21.send(Unknown Source)
at org.xrpl.xrpl4j.client.XrplClient.ledger(XrplClient.java:365)
at org.xrpl.xrpl4j.samples.SendXrp.main(SendXrp.java:75)
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.ZonedDateTime` from String "2021-May-29 11:17:31.000000000 UTC": Failed to deserialize java.time.ZonedDateTime: (java.time.format.DateTimeParseException) Text '2021-May-29 11:17:31.000000000 UTC' could not be parsed at index 5
at [Source: (String)"{"ledger":{"accepted":true,"account_hash":"6EA245EC465C5297BCB94DC8FAB9B9FBB382C6C74D0EA40704FED9880B044A6F","close_flags":0,"close_time":675602251,"close_time_human":"2021-May-29 11:17:31.000000000 UTC","close_time_resolution":10,"closed":true,"hash":"D46188330B232EED1305BF68FE7095AAE337F8CF76167B8AFE9A0468C5DE9216","ledger_hash":"D46188330B232EED1305BF68FE7095AAE337F8CF76167B8AFE9A0468C5DE9216","ledger_index":"17915159","parent_close_time":675602250,"parent_hash":"7C2ED475EA8672125FAF7B20A7DAD"[truncated 352 chars]; line: 1, column: 168] (through reference chain: org.xrpl.xrpl4j.model.client.ledger.ImmutableLedgerResult$Json["ledger"]->org.xrpl.xrpl4j.model.ledger.ImmutableLedgerHeader$Json["close_time_human"])
at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1702)
at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:947)
at com.fasterxml.jackson.datatype.jsr310.deser.JSR310DeserializerBase._handleDateTimeException(JSR310DeserializerBase.java:129)
at com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.deserialize(InstantDeserializer.java:235)
at com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.deserialize(InstantDeserializer.java:50)
at com.fasterxml.jackson.databind.deser.std.ReferenceTypeDeserializer.deserialize(ReferenceTypeDeserializer.java:185)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:194)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:166)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1315)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:331)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:194)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:166)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1315)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:331)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4524)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3466)
at org.xrpl.xrpl4j.client.JsonRpcClient.send(JsonRpcClient.java:118)
... 11 more
Caused by: java.time.format.DateTimeParseException: Text '2021-May-29 11:17:31.000000000 UTC' could not be parsed at index 5
at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2050)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1878)
at com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer.deserialize(InstantDeserializer.java:229)
... 30 more
Process finished with exit code 1
Problem solved. It's an issue working with german locale. I'm using OpenJDK 15.0.2.
var now = new Date();
var pattern = "yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z";
System.out.println("Locale.ENGLISH: " + new SimpleDateFormat(pattern, Locale.ENGLISH).format(now));
System.out.println("Locale.GERMAN: " + new SimpleDateFormat(pattern, Locale.GERMAN).format(now));
Returns Locale.ENGLISH: 2021-Jun-03 08:46:45.000000393 CEST Locale.GERMAN: 2021-Juni-03 08:46:45.000000393 MESZ Locale.ENGLISH: 2021-Aug-03 08:47:55.000000137 CEST Locale.GERMAN: 2021-Aug.-03 08:47:55.000000137 MESZ
Solution
Run your Java 9 and later (including Java 11) with the system property java.locale.providers defined like this (stackoverflow):
java -Djava.locale.providers=COMPAT,CLDR YourApp
Originally described issue went away and example code is now working as expected.
Solution returns Locale.ENGLISH: 2021-Jun-03 08:51:38.000000377 CEST Locale.GERMAN: 2021-Jun-03 08:51:38.000000377 MESZ Locale.ENGLISH: 2021-Aug-03 09:03:21.000000753 CEST Locale.GERMAN: 2021-Aug-03 09:03:21.000000753 MESZ
I copy & paste java code from the example and hit run. It throws following exception below. I cannot find my mistake. Does anyone have an idea?
Dependecies implementation("org.glassfish.jaxb:jaxb-runtime:2.3.2") implementation group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '3.0.1' implementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '3.0.1' implementation group: 'org.json', name: 'json', version: '20210307' implementation group: 'commons-codec', name: 'commons-codec', version: '1.15' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.9.1' implementation group: 'org.xrpl', name: 'xrpl4j-address-codec', version: '2.0.0' implementation group: 'org.xrpl', name: 'xrpl4j-keypairs', version: '2.0.0' implementation group: 'org.xrpl', name: 'xrpl4j-model', version: '2.0.0' implementation group: 'org.xrpl', name: 'xrpl4j-client', version: '2.0.0' implementation group: 'org.xrpl', name: 'xrpl4j-crypto-bouncycastle', version: '2.0.0'
testCompile group: 'junit', name: 'junit', version: '4.12' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
Execption