Quarkus: Resource bundle not accessible in dev mode

Created on 24 Mar 2020  路  8Comments  路  Source: quarkusio/quarkus

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
kinquestion

Most helpful comment

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

All 8 comments

Hi,

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

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

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.

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.

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.

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

It worked. Should the ticket be closed?

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.

Was this page helpful?
0 / 5 - 0 ratings