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

java.lang.IllegalStateException: AmbiguousConfiguration detected for 'org.javamoney.moneta.Money.defaults.roundingMode' #393

Open
debraj-manna opened this issue Jun 1, 2023 · 5 comments
Labels

Comments

@debraj-manna
Copy link

I am using moneta 1.4.2 with spring-boot 3.0.6 and Java 17.

I am seeing an exception trace like below. Can someone let me know what could be causing this and how can I get around this?

Jun 01, 2023 7:39:38 PM org.javamoney.moneta.spi.MonetaryConfig <init>
SEVERE: Error loading javamoney.properties, ignoring jar:file:/Users/debrajmanna/.m2/repository/com/spotnana/lambda/profile-uploads/0.0.1-SNAPSHOT/profile-uploads-0.0.1-SNAPSHOT.jar!/javamoney.properties
java.lang.IllegalStateException: AmbiguousConfiguration detected for 'org.javamoney.moneta.Money.defaults.roundingMode'.
        at org.javamoney.moneta.spi.MonetaryConfig.updateConfig(MonetaryConfig.java:86)
        at org.javamoney.moneta.spi.MonetaryConfig.<init>(MonetaryConfig.java:49)
        at org.javamoney.moneta.spi.MonetaryConfig.<clinit>(MonetaryConfig.java:35)
        at org.javamoney.moneta.spi.DefaultMonetaryCurrenciesSingletonSpi.getDefaultProviderChain(DefaultMonetaryCurrenciesSingletonSpi.java:121)
        at org.javamoney.moneta.spi.DefaultMonetaryCurrenciesSingletonSpi.collectProviders(DefaultMonetaryCurrenciesSingletonSpi.java:91)
        at org.javamoney.moneta.spi.DefaultMonetaryCurrenciesSingletonSpi.getCurrencies(DefaultMonetaryCurrenciesSingletonSpi.java:45)
        at javax.money.spi.MonetaryCurrenciesSingletonSpi.getCurrency(MonetaryCurrenciesSingletonSpi.java:76)
        at javax.money.Monetary.getCurrency(Monetary.java:382)
        at org.javamoney.moneta.FastMoney.<clinit>(FastMoney.java:118)
        at com.spotnana.common.MoneyUtils.protoMoney(MoneyUtils.java:104)
@keilw keilw transferred this issue from JavaMoney/jsr354-api Jun 2, 2023
@keilw
Copy link
Member

keilw commented Jun 2, 2023

Moved that one to the RI.
It is a known issue during test execution, related to #370, mostly because the maven test module does not declare a Jigsaw module-info of its own.
To try reproduce it fro a standalone setup, @debraj-manna could you please provide a snippet from the MoneyUtils class if you can?

@debraj-manna
Copy link
Author

@keilw

  public static com.spotnana.proto.v1.common.Money protoMoney(double amount, String currency) {
    return protoMoney(FastMoney.of(BigDecimal.roundToScale5(amount), currency));
  }

@keilw keilw added the analysis label Jan 24, 2024
@keilw
Copy link
Member

keilw commented Jan 27, 2024

@debraj-manna Does it still happen with 1.4.4? And if so, is the problem restricted to JUnit tests?

@kewne
Copy link
Contributor

kewne commented Apr 20, 2024

@keilw I just noticed that there is a javamoney.properties~ (notice the tilde) in https://github.com/JavaMoney/jsr354-ri/tree/3415a66a09326f8e8bf07c21213b4d7eb4cf561a/moneta-core/src/main/resources, which is incredibly suspicious.

@keilw
Copy link
Member

keilw commented Apr 20, 2024

@kewne That's a template or backup, it should not be loaded, and the ambiguity comes from problems with MonetaryConfig: #370

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

No branches or pull requests

3 participants