Skip to content

MissingResourceException: Can’t find bundle for base name resources.controls.controls_res, locale en

I can’t understand what the problem is, why he swears and can’t find locale en. Is there a problem with paths or boundle names?

The legacy project, written 15 years ago, used to be in Ant, now it was translated to Gradle, this error has appeared. It builds on Ant without problems.

P.S. I marked the lines to which the errors refer separately in the classes.


    at org.opensourcephysics.controls.OSPLog.<init>(
    at org.opensourcephysics.controls.OSPLog.getOSPLog(
    at org.opensourcephysics.cabrillo.tracker.Tracker.loadPreferences(
    at org.opensourcephysics.cabrillo.tracker.Tracker.<clinit>(
Caused by: java.util.MissingResourceException: Can't find bundle for base name org.opensourcephysics.resources.controls.controls_res, locale en
Caused by: java.util.MissingResourceException: Can't find bundle for base name org.opensourcephysics.resources.controls.controls_res, locale en

    at java.util.ResourceBundle.throwMissingResourceException(
    at java.util.ResourceBundle.getBundleImpl(
    at java.util.ResourceBundle.getBundle(
    at org.opensourcephysics.controls.ControlsRes.<clinit>(
    ... 4 more
Caused by: java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(
    at java.util.Properties.load0(
    at java.util.Properties.load(
    at java.util.PropertyResourceBundle.<init>(
    at org.opensourcephysics.resources.controls.controls_res.<init>(
    at org.opensourcephysics.resources.controls.controls_res.<init>(
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
    at java.lang.reflect.Constructor.newInstance(
    at java.lang.Class.newInstance(
    at java.util.ResourceBundle$Control.newBundle(
Caused by: java.lang.NullPointerException

    at java.util.ResourceBundle.loadBundle(
    at java.util.ResourceBundle.findBundle(
    at java.util.ResourceBundle.findBundle(
    at java.util.ResourceBundle.getBundleImpl(
    ... 6 more
Exception in thread "main" 
Execution failed for task ':Tracker.main()'.

As you can see from the logs, all errors are caused due to the fact that it cannot find * locale en *.

Класс controls_res:

public class controls_res extends PropertyResourceBundle {
  // relative path to strings
  static String res = ""; //$NON-NLS-1$

   * Constructor tools
   * @throws IOException
  public controls_res() throws IOException {
    this(controls_res.class.getResourceAsStream(res)); 23 STRING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

   * Constructor tools
   * @param stream
   * @throws IOException
  public controls_res(InputStream stream) throws IOException {
    super(stream);  // 32 STRING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Class controls_res_en:

 * English resource loader for OSP controls class.  Resource strings are obtained from superclass.
 * @author Wolfgang Christian
public class controls_res_en extends controls_res {
   * Constructor controls_res_en
   * @throws IOException
  public controls_res_en() throws IOException {

Class ControlsRes:

public class ControlsRes {
  // static constants for speed
  public static String ANIMATION_NEW;
  public static String ANIMATION_INIT;
  public static String ANIMATION_STEP;
  public static String ANIMATION_RESET;
  public static String ANIMATION_START;
  public static String ANIMATION_STOP;
  public static String ANIMATION_RESET_TIP;
  public static String ANIMATION_INIT_TIP;
  public static String ANIMATION_START_TIP;
  public static String ANIMATION_STOP_TIP;
  public static String ANIMATION_NEW_TIP;
  public static String ANIMATION_STEP_TIP;
  public static String CALCULATION_CALC;
  public static String CALCULATION_RESET;
  public static String CALCULATION_CALC_TIP;
  public static String CALCULATION_RESET_TIP;
  public static String XML_NAME;
  public static String XML_VALUE;
  static final String BUNDLE_NAME = "org.opensourcephysics.resources.controls.controls_res"; //$NON-NLS-1$
  static ResourceBundle res;

  // private constructor because all methods are static
  private ControlsRes() {}

  static {
    String language = Locale.getDefault().getLanguage();
    Locale resourceLocale = Locale.ENGLISH;
    for(Locale locale : OSPRuntime.getInstalledLocales()) {
      if(locale.getLanguage().equals(language)) {
        resourceLocale = locale;
    res = ResourceBundle.getBundle(BUNDLE_NAME, resourceLocale); // 55 String!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  private static String getString(final ResourceBundle bundle, final String key) {
    try {
      return bundle.getString(key);
    } catch(final MissingResourceException ex) {
      return '|'+key+'|';

  public static void setLocale(Locale locale) {
    res = ResourceBundle.getBundle(BUNDLE_NAME, locale);

   * Gets the localized value of a string. If no localized value is found, the
   * key is returned surrounded by exclamation points.
   * @param key the string to localize
   * @return the localized string
  static public String getString(String key) {
    try {
      return res.getString(key);
    } catch(MissingResourceException ex) {
      return "!"+key+"!"; //$NON-NLS-1$ //$NON-NLS-2$

  * Gets the local strings.  Static strings are used for speed to avoid having to call the resource object.
  private static void setLocalStrings() {
    ANIMATION_NEW = getString(res, "ANIMATION_NEW");                 //$NON-NLS-1$
    ANIMATION_INIT = getString(res, "ANIMATION_INIT");               //$NON-NLS-1$
    ANIMATION_STEP = getString(res, "ANIMATION_STEP");               //$NON-NLS-1$
    ANIMATION_RESET = getString(res, "ANIMATION_RESET");             //$NON-NLS-1$
    ANIMATION_START = getString(res, "ANIMATION_START");             //$NON-NLS-1$
    ANIMATION_STOP = getString(res, "ANIMATION_STOP");               //$NON-NLS-1$
    ANIMATION_RESET_TIP = getString(res, "ANIMATION_RESET_TIP");     //$NON-NLS-1$
    ANIMATION_INIT_TIP = getString(res, "ANIMATION_INIT_TIP");       //$NON-NLS-1$
    ANIMATION_START_TIP = getString(res, "ANIMATION_START_TIP");     //$NON-NLS-1$
    ANIMATION_STOP_TIP = getString(res, "ANIMATION_STOP_TIP");       //$NON-NLS-1$
    ANIMATION_NEW_TIP = getString(res, "ANIMATION_NEW_TIP");         //$NON-NLS-1$
    ANIMATION_STEP_TIP = getString(res, "ANIMATION_STEP_TIP");       //$NON-NLS-1$
    CALCULATION_CALC = getString(res, "CALCULATION_CALC");           //$NON-NLS-1$
    CALCULATION_RESET = getString(res, "CALCULATION_RESET");         //$NON-NLS-1$
    XML_NAME = getString(res, "XML_NAME");                           //$NON-NLS-1$
    XML_VALUE = getString(res, "XML_VALUE");                         //$NON-NLS-1$

введите сюда описание изображения

enter image description here


Created new empty files and rewrote the contents from the same files – the problem is gone. Apparently, the file encoding collectors could not read. After all, the legacy project has been passed from hand to hand 100 times.