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

Resource bundle not accessible in dev mode #8103

Closed
AmsterdamFilho opened this issue Mar 24, 2020 · 8 comments
Closed

Resource bundle not accessible in dev mode #8103

AmsterdamFilho opened this issue Mar 24, 2020 · 8 comments
Labels
kind/question Further information is requested

Comments

@AmsterdamFilho
Copy link

Describe the bug
When executing quarkus in dev mode, if a resource bundle is added to the resources folder, e.g., to src/main/resources/i18n/i18n.properties, calling the method ResourceBundle.getBundle("i18n/i18n") will throw MissingResouce exception. This is happening on quarkus 1.3.0.

Expected behavior
ResourceBundle successfully loads the bundle.

Actual behavior
ResourceBundle throws MissingResource exception.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new project
  2. Add a resource bundle
  3. Write code to access it
  4. Run quarkus in dev mode
  5. Verify the bundle is not accessible
  6. Package the app
  7. Run the application in normal mode
  8. Verify the bundle is now accessible
@AmsterdamFilho AmsterdamFilho added the kind/bug Something isn't working label Mar 24, 2020
@geoand
Copy link
Contributor

geoand commented Mar 24, 2020

Hi,

Just for our information, is this something that was working in a previous version of Quarkus?

@geoand
Copy link
Contributor

geoand commented Mar 24, 2020

It would be nice if you provided a reproducer for this, because I was not able to reproduce the problem in a test project.

@AmsterdamFilho
Copy link
Author

The reproducer is here https://github.com/AmsterdamFilho/quarkus-poc

But actually, the problem only happens when the instruction ResouceBundle.getBundle("i18n/i18n") is on a library, which unfortunately is my case.

@AmsterdamFilho
Copy link
Author

To use the reproducer, just execute the project in dev mode and open swagger-ui. The only endpoint will throw the MissingResource exception. If you package the application, though, it will not.

@AmsterdamFilho
Copy link
Author

AmsterdamFilho commented Mar 24, 2020

I had many issues similar to this one before version 1.3.0, when things would work after package, but not in dev mode. They were all solved by the new ClassLoader.

@gsmet
Copy link
Member

gsmet commented Mar 24, 2020

I would try with ResourceBundle.getBundle("i18n/i18n", Locale.getDefault(), Thread.currentThread().getContextClassLoader()).

@AmsterdamFilho
Copy link
Author

It worked. Should the ticket be closed?

@geoand
Copy link
Contributor

geoand commented Mar 24, 2020

I think it should.

In general, all resources should be loaded like @gsmet mentions, since it's the only guaranteed way to have it work in dev mode.

@geoand geoand closed this as completed Mar 24, 2020
@gsmet gsmet added kind/question Further information is requested and removed kind/bug Something isn't working triage/backport? labels Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants