JavaMoney / jsr354-ri

JSR 354 - Moneta: Reference Implementation
Other
334 stars 100 forks source link

UnknownCurrencyException: Unknown currency code: XXX #417

Open SamuelPavlik opened 2 months ago

SamuelPavlik commented 2 months ago

I am using Kotlin and Moneta 1.4, and have them included in my classpath :

In my application I have the following code:

fun doSomething(paymentFee: Double, currency: String) {
    val paymentFee: MonetaryAmount = FastMoney.of(paymentFee, currency),
}

When calling the code in one of the environments that I'm using, I'm consistently getting the following error:

"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)\n\tat org.javamoney.moneta.FastMoney.<clinit>(FastMoney.java:119)

I checked the data and there's no XXX when FastMoney.of() is getting called. Since it's ExceptionInInitializerError (error during static initialization) I presume it's caused by this line in the FastMoney class:

public static final FastMoney MAX_VALUE = new FastMoney(Long.MAX_VALUE, Monetary.getCurrency("XXX"));

However, I don't know why this error only occurs in that one environment, and how to fix it.

Thanks for any help in advance.