jsr354-api
jsr354-api copied to clipboard
MonetaryException: No MonetaryAmountsSingletonSpi loaded in Kubernetes
I want to draw some community attention to my question on StackOverflow. Don't want it to be copy-pasted here that's why I only left a link to StackOverflow.
Thanks in advance for any feedback.
I hope @atsticks might have a chance to look at it, he's the Kubernetes guy, I am not working with Kubernetes right now, so I can't help with that I'm afraid.
@keilw thank you so much for answering. I don't rule out that the problem may be outside of Kubernetes. Unfortunately, this problem is pretty vague.
I will give you any information you needed to solve that problem.
@atsticks sorry for my impatience, but could you have a look at my problem? Any advice will be very valuable for me.
There was at least one ticket in Moneta specific to Java 11 (although it may not even be a Moneta problem) and Spring Boot, so did you get a chance to try it with Java 8 to 10 as well? Then it'll show, if it is related to Kubernetes or maybe started with Java 11, which as we know includes many changes that break things, therefore please try an older JDK, too.
@keilw I finally came up with a solution: https://stackoverflow.com/a/61715268/3456163
I've discovered that:
- The problem is not related to Kubernetes at all.
- The problem is not reproduced on Java 8. Thanks for your suggestion to check this.
For more details see this repo: https://github.com/iakunin/moneta-concurrent-init
What can we do with that problem? Should it be solved here or it'd be better to bug-report in some other project?
Thanks for sharing the insight. It could be related to this one https://github.com/JavaMoney/jsr354-ri/issues/331 where the reporter asked to close it, but we could see, if there is some problem with concurrency starting with Java 11 that does not only affect Kubernetes or Spring Boot.
Looks like the same issue to me that we had as well in JavaMoney/jsr354-ri#331.
In your prototype you do the initial call the Moneta within a parallel stream.
Somehow it seems that Spring Boot 2.x jars breaks Moneta SPI with Java 11 and initialization in parallel streams.
I am not that into the OpenJDK thing here I'm afraid, so hope either @otaviojava (who seems to have done something in OpenJDK) might help you with that one. I also pinged @vgrazi who did e.g. https://github.com/vgrazi/java-concurrent-animated a long time ago, but he's officially "Emeritus"(as Spec Lead) but if he had time, of course he'd also be more than welcome to contribute.
Btw, are either of you JCP members at least Associate members? Otherwise it might be tricky with PRs for that. All the mentioned including Victor are JCP members and are or were EG members.
If it's Moneta SPI then I guess it should be in a different repo.
I'm not the deepest concurrency guy here, but one problem could be related to the use of MonetaryConfig
in moneta, while the preferred approach would be DefaultConfigProvider
which at least uses a ConcurrentHashmap
under the hood. It's a wild guess but have a look. If that's the case it would be mostly in the RI.
I guess the problem is, in the ServiceProvider
implementations ServiceLoader.load
method is called with single parameter. Which cause it to use Thread.currentThread().getContextClassLoader()
. Which is weirdly in java11 fail to find the services. I tried to copy PriorityAwareServiceProvider
and just change that line to ServiceLoader.load(serviceType, MonetaTestApplication.class.getClassLoader()
and in the main
method's static block call Bootstrap.init(new MyShinyNewServiceProvider())
in the provided project to reproduce the error, and it works pretty well. By the way it solves the Currency Not found exception too.
Do you think you could create a PR based on those findings?
here the PR: https://github.com/JavaMoney/jsr354-ri/pull/333
If it's possible to upload snapshot somewhere, I can check if it helps in my repo with bug reproduction.
moneta-core-1.4.1-SNAPSHOT.jar.zip you can try with this jar :)
Tested with the repository referenced in https://github.com/JavaMoney/jsr354-ri/issues/331. The PR fixes the issue :+1:
Thanks a lot, I'll check it tomorrow evening or on the weekend. @utkanozyurek it seems you are not a JCP Member. Would you consider joining the JCP? Everyone else is equally welcome, and although we'll wait for the EC to approve the MR1 before publishing a service update, we should merge this very quickly but from a process point it is better, if authors of a PR also joined the JCP at least on the "Associate" level, which is easiest even for employees of a company.
Thanks @keilw , I needed to update the personal information in JCP account before applying for associate membership, it's waiting for JCP PMO review.
moneta-core-1.4.1-SNAPSHOT.jar.zip you can try with this jar :)
@utkanozyurek problem is not reproduced in my repo anymore. Many thanks to you! :)