# java.util.MissingResourceException: Can't find bundle for base name messages, locale en_US

- **ID:** `java/missing-resource-bundle-exception`
- **Domain:** java
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The ResourceBundle.getBundle method cannot locate a .properties file for the given base name and locale, often due to a missing file, incorrect path, or classpath issue.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Java 8 | active | — | — |
| Java 11 | active | — | — |
| Java 17 | active | — | — |
| Java 21 | active | — | — |

## Workarounds

1. **Ensure the properties file (e.g., messages.properties) is in the classpath under the correct package path, e.g., src/main/resources/com/example/messages.properties for base name 'com.example.messages'.** (90% success)
   ```
   Ensure the properties file (e.g., messages.properties) is in the classpath under the correct package path, e.g., src/main/resources/com/example/messages.properties for base name 'com.example.messages'.
   ```
2. **Use ResourceBundle.getBundle with a ClassLoader: ResourceBundle.getBundle("messages", locale, Thread.currentThread().getContextClassLoader())** (80% success)
   ```
   Use ResourceBundle.getBundle with a ClassLoader: ResourceBundle.getBundle("messages", locale, Thread.currentThread().getContextClassLoader())
   ```

## Dead Ends

- **** — An empty file may cause other parsing errors or missing key exceptions; the file must contain valid key-value pairs for the application to function. (50% fail)
- **** — ResourceBundle expects the file to be in the same package as the class or in a specified path; incorrect placement leads to the same error. (70% fail)
