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

MonetaryException: No MonetaryAmountsSingletonSpi loaded in Kubernetes #129

Open
iakunin opened this issue Apr 28, 2020 · 19 comments
Open

Comments

@iakunin
Copy link

iakunin commented Apr 28, 2020

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.

@keilw
Copy link
Member

keilw commented Apr 28, 2020

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 keilw changed the title MonetaryException: No MonetaryAmountsSingletonSpi loaded MonetaryException: No MonetaryAmountsSingletonSpi loaded in Kubernetes Apr 28, 2020
@keilw keilw added the analysis label Apr 28, 2020
@iakunin
Copy link
Author

iakunin commented Apr 28, 2020

@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.

@iakunin
Copy link
Author

iakunin commented May 7, 2020

@atsticks sorry for my impatience, but could you have a look at my problem? Any advice will be very valuable for me.

@keilw
Copy link
Member

keilw commented May 7, 2020

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.

@iakunin
Copy link
Author

iakunin commented May 10, 2020

@keilw I finally came up with a solution: https://stackoverflow.com/a/61715268/3456163

I've discovered that:

  1. The problem is not related to Kubernetes at all.
  2. 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?

@keilw
Copy link
Member

keilw commented May 10, 2020

Thanks for sharing the insight. It could be related to this one JavaMoney/jsr354-ri#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.

@ncwoehler
Copy link

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.

@keilw
Copy link
Member

keilw commented May 18, 2020

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.

@keilw keilw added the deferred label May 18, 2020
@keilw keilw added this to the .Next milestone May 18, 2020
@keilw
Copy link
Member

keilw commented May 18, 2020

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.

@keilw
Copy link
Member

keilw commented May 18, 2020

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.

@utkanozyurek
Copy link

utkanozyurek commented Jun 3, 2020

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.

@keilw
Copy link
Member

keilw commented Jun 3, 2020

Do you think you could create a PR based on those findings?

@utkanozyurek
Copy link

here the PR: JavaMoney/jsr354-ri#333

@iakunin
Copy link
Author

iakunin commented Jun 4, 2020

If it's possible to upload snapshot somewhere, I can check if it helps in my repo with bug reproduction.

@utkanozyurek
Copy link

moneta-core-1.4.1-SNAPSHOT.jar.zip
you can try with this jar :)

@ncwoehler
Copy link

Tested with the repository referenced in JavaMoney/jsr354-ri#331. The PR fixes the issue 👍

@keilw
Copy link
Member

keilw commented Jun 4, 2020

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.

@utkanozyurek
Copy link

Thanks @keilw , I needed to update the personal information in JCP account before applying for associate membership, it's waiting for JCP PMO review.

@iakunin
Copy link
Author

iakunin commented Jun 5, 2020

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! :)

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

No branches or pull requests

5 participants