Java 1.5, Java EE 5, WAS 6.1: Exception loading a resource bundle with ResourceBundle.getBundle(…)

StackOverflow https://stackoverflow.com/questions/812802

  •  03-07-2019
  •  | 
  •  

Question

Here's another issues that we are facing while migrating our application from current production environment to the new data center environment (see details below)

  • Current Production Environment : Java 1.4, Java EE 3, WAS 5.1, JSF 2.1
  • New Environment: Java 1.5, Java EE 5, WAS 6.1, JSF 2.1

Here we have a third party jar file with the following structure (check the image - pardon me hiding some details)
alt text


This class has the code to load the database properties from a ResourceBundle (db.properties). Here is the code rendered out by Cavaj:

    private static ResourceBundle getDBProperties()
    {
        if(dbProperties == null)
        {
            dbProperties = ResourceBundle.getBundle("db");
        }
        return dbProperties;
    }

This application is working fine on the current environment. But somehow when we move the application to the new environment we get a "MissingResourceException" (see below):

Caused by: java.util.MissingResourceException: Can't find bundle for
base name db, locale en_US
at
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:863)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:832)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
at
com.myco.wo.vs.util.OrderLovUtilities.getDBProperties(OrderLovUtilities.java:195)

We tried following workarounds but none worked:

  1. Renamed the db.properties as db_en_US.properties
  2. Putting the properties file in the jar
  3. moving the jar file at EAR level.

Please suggest on what could be wrong here. And what can we do to get it working :)

Note: File db.properties is located under the WEB-INF/classes directory. Also we tried putting it on the above mentioned locations but to no avail.

Regards,
- Ashish

Was it helpful?

Solution

Try to change classloader ordering in settings of your ent. application in the admin console (from PARENT_FIRST to PARENT_LAST) on both EAR and WAR levels.

It seems to me that 3rd party class (com.myco.wo.vs.util.OrderLovUtilities) is not loaded from your jar file in WEB-INF/lib, but it is rather comes from some other location on the server. Its classloader then does not see the property file.

If that is the issue, changing the classloader ordering should cause the expected copy of the class to load.

Also, the classloader viewer in the admin console can put some light on that.

OTHER TIPS

Have you tried putting your db.properties file under WEB-INF/classes directory?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top