I am using Moneta 1.4, and has in my classpath
- moneta-core-1.4.4.jar
- money-api-1.1.jar
I was checking classpath, and I’ve seen (also in documentation) that moneta uses ServiceProviders functionality from Java language, to extend money-api functionality.
The thing is, randomly, and let’s say in a 5% of the times, when I try to use FastMoney.of , I got the exception below.
Simple call that fails sometime:
amount = FastMoney.of( amount.value, amount.currency, ),
Simple expcetion (Mind on line numbers pls)
"exception": "java.lang.ExceptionInInitializerError: Exception javax.money.UnknownCurrencyException: Unknown currency code: XXX [in thread "Thread-572"] at javax.money.spi.MonetaryCurrenciesSingletonSpi.getCurrency(MonetaryCurrenciesSingletonSpi.java:78) at javax.money.Monetary.getCurrency(Monetary.java:382)ntat org.javamoney.moneta.FastMoney.<clinit>(FastMoney.java:119)
Any idea why this could be happening? I am concerned that it fails randomly so I can not control it.
I’ve checked code and I presume, as DefaultMonetaryCurrenciesSingletonSpi::getDefaultProviderChain() returns a list of privders in an ARBITRARY order, some provider I have may not recognize the “no currency code”, but sadly can not prove it.
Thanks for any help in advance.
I expect simple FastMoney.of(1, “EUR”) alwasy work.
Sergio Soria Olivares is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.