Locale is lost in ResourceBundle

Hi,
I�m having a severe problem with the ResourceBundle. For some reason, the locale object in the ResourceBundle is not identical with the one I pass to it when calling:
// CORRECT LOCALE
logger.debug("BEFORE LOCALE: " + locale.getDisplayLanguage() + "_" + locale.getCountry() + "_" + locale.getVariant());
ResourceBundle rb = null;
try {
     //Get the property file for the current Locale
     rb = ResourceBundle.getBundle("TestBundle", locale);
     // WRONG LOCALE !!
     logger.debug("AFTER LOCALE: " + rb.getLocale().getDisplayLanguage() + "_" + rb.getLocale().getCountry() + "_" + rb.getLocale().getVariant());
} catch (MissingResourceException e) {
     logger.error("Unable to load resource TestBundle");
Before passing the locale object to the ResourceBundle the values are "German_DE_EUR" which is correct, but when I check out the values of the locale object contained in the ResourceBundle I get "English" and nothing else.
The problem here is that this causes me to get the wrong texts! What could be happening here!??
Thanks in advance.
Regards,
Michael

You should always implement the default
TestBundle.[class | properties]. Preferably, you would then
implement additional bundles from this base.I also agree with this.
Another question, where are u using this code? In JSP or in servlet class? If JSP, Struts have some tags for i18n. Just use them. It will do the other stuffs. Though I used Struts for learning only, it worked well for me.
Thanks
Hafizur Rahman
SCJP

Similar Messages

  • Error (2931) VMM is unable to complete the request. The connection to the VMM agent on the virtualization server (host.domain.local) was lost.

    Experts,
    kindly advice for this error when create vm from a templates, while i'm not having this issue when create the vm to another host from the same templates,
    firewall is disabled and no antivirus on the host.
    The network and the ping is very stable, and the WS-Management service is running on the host,
    Host  : windows server 2012 R2
    VMM : 2012 R2 3.2.7895.0
    VMM updated from RU2 to RU5
    Error (2931)
    VMM is unable to complete the request. The connection to the VMM agent on the virtualization server (host.domain.local) was lost.
    Unknown error (0x80338029)
    Recommended Action
    Ensure that the Windows Remote Management (WS-Management) service and the VMM agent are installed and running and that a firewall is not blocking HTTPS traffic.
    This can also happen due to DNS issues. Try and see if the server (ms-lab-01.eccsolutions.local) is reachable over the network and can be looked up in DNS. You can ping the virtualization server from VMM management server and make sure that the
    IP address returned matches the IP address locally obtained from the virtualization server.
    If the error still persists, restart the virtualization server, and then try the operation again.
    Ahmad Samir | MCSE 2003, MCSE 2012 Private Cloud | MCTS: SCOM 2007, Lync 2010, Exchange 2010.

    Ok  I will try another template,
    and the drop happen in the customization after deploying the VHDX file as my first image.
    I had this answer from partner forum. but i didn't try it yet
    Backup your VMM database and then check the
    tbl_VMM_Lock table in the
    VMM database to see if it has any locks listed, do this after stopping the System Center Virtual Machine Manager Service.
    If there are locks listed in the tbl_VMM_Lock
    table you can clear them by executing the prc_VMM_ReleaseAllLocks
    stored procedure.
    Ahmad Samir | MCSE 2003, MCSE 2012 Private Cloud | MCTS: SCOM 2007, Lync 2010, Exchange 2010, Server Virtualization.

  • I set my cRIO from 'DHCP' to 'link local' and lost contact with it.

    I set my cRIO from 'DHCP' to 'link local' and lost contact with it.
     I changed the setting at the placed labeled "2" to link local only, then I think I hit save at "3".  Then poof, I had no network contact with my cRIO.  
    I tried;
        Hitting the reset button
        Opening a closing MAX
        Going to safe mode
        Throwing the Reset IP switch 
        Power cycling the cRIO
        Running cat 5 cable directly from the Host to my target
    None of it worked, and I have no contact with my cRIO.
    This is what MAX looks like now.  How can I fix this?
    Solved!
    Go to Solution.

    Make sure to disable the firewall on your computer.
    Otherwise you can check through the steps in this documentation:
    http://digital.ni.com/public.nsf/allkb/ABE4BC247E8​AC9BC8625734E005CAB42
    Note specifically that one option is to read the console out from the target VIA the serial port will a null modem cable during boot and it will indicate what IP the system is using.
    Craig H. | CLA | Systems Engineer | National Instruments

  • Locale Settings lost on mobile client 7.8.2.14 after creation of BIP report

    Hi All,
    we went live with BI Publisher reports (Siebel 7.8.2.14) at the beginning of June.
    Now some of our users are having trouble with their mobile web client.
    For example our colleagues in Poland have their Windows XP regional settings set to "Polish". It will make Siebel use date format for all date fields (e.g. activity start date) display as YYYY-MM-DD - this works just fine until user is creating a BIP report. After successfull report creation, all locale settings in the mobile client are lost. Instead of YYYY-MM-DD, the dates are displayed in DD.MM.YYYY and creation of new records produces and error. Also, currency and number formats are mixed up.
    I assume it's a bug - anyone hit this before?
    Edited by: Penky on Jun 17, 2011 11:38 AM

    Yes, we finally decided to do so!
    The main reason was that we had a lot of new report change requests and did not want to do the work twice (now in Actuate and then again in BIP). Also we plan our 8.x upgrade for second half of 2011 so this was already some kind of preparation, so we can completely focus on the upgrade afterwards and don't need to hassle around with the reports as well.
    issues we're still facing include "user's are not able to run reports after they change their position" or "List reports can only be run for few records, otherwise the search spec hit's an IO field's length limitation" or "report popup can not be suppressed although there's no useful information in it" (not to forget the one described in this thread) and some others.
    Well ... after 1 1/2 years since I downloaded the first integration QF the BIP journey still does not end - it's like it just started :)

  • Pacman's local database lost

    Wait, wait, before you tell me to look at the other almost identical thread and the wiki entry - I already did . This is the difference: I still have pacman.log and my entire /var/ is safe and sound. The problem is this:
    Errors occurred, no packages were upgraded.
    error : /var/lib/pacman//local : No such file or directory
    That comes up after trying to re-install pactools from AUR, and I gather that some process is erroneously looking for //local, a simple syntax error. I did pt-pacman-cage (a few days ago, error-free) and I installed kernel26-ck (immediately before this problem occured) so I think installing the new kernel before "uncaging" pacman is causing this. I'm posting on the forum to see if I could avoid re-installing all the packages like the wiki says (I've already made pkglist). Would Xyne's perl script help me? Can I uncage pacman manually? Is  my old vanilla kernel still here or has it been overwritten? Will our hero survive the Sphinx's questioning or will he be lost forever in the Binary Maze? Stay tuned!
    Last edited by Csosa (2010-04-30 02:31:39)

    Csosa wrote:
    Wait, wait, before you tell me to look at the other almost identical thread and the wiki entry - I already did . This is the difference: I still have pacman.log and my entire /var/ is safe and sound. The problem is this:
    Errors occurred, no packages were upgraded.
    error : /var/lib/pacman//local : No such file or directory
    That comes up after trying to re-install pactools from AUR, and I gather that some process is erroneously looking for //local, a simple syntax error. I did pt-pacman-cage (a few days ago, error-free) and I installed kernel26-ck (immediately before this problem occured) so I think installing the new kernel before "uncaging" pacman is causing this. I'm posting on the forum to see if I could avoid re-installing all the packages like the wiki says (I've already made pkglist). Would Xyne's perl script help me? Can I uncage pacman manually? Is  my old vanilla kernel still here or has it been overwritten? Will our hero survive the Sphinx's questioning or will he be lost forever in the Binary Maze? Stay tuned!
    Try making it so the db is mounted in rc.local and not by fstab.
    I use
    stat_busy "Mounting Pacman DB"
    mount -o loop,noatime,noauto /var/lib/pacman.db /var/lib/pacman
    stat_done

  • Need to find out which apps were purchased previously (local copies lost)

    Rebuilding after losing the main HD on a MacBook (no, there was no backup, sigh). There were a few dozen iPhone apps, and the first iPhone sync wiped them from the iPhone. So we have no local list of purchased iPhone apps.
    Is there an easy way to find out from the App Store which apps have been purchased with an account in the past?
    Thanks

    in iTunes, go to the iTunes Store, on the right side of the store you have some "Quick Links", one is a link to your Account. There you can select your "Purchase History" and you see everything you were downloading... hope that helps

  • Locale gets lost in itemEditor

    My app need only use the en-US locale.
    Because numbers like 1,000.00 were being displayed as 1 000,00 in spark Formatters and components, I figured out that it is necessary to declare this for the application in a css declaration.
    This works fine until I work with numbers in a datagrid itemEditor. The locale declaration is defaulting back to 1 000,00 formatting.
    I assume that the application-wide declaration is ignored somehow. Am I missing something?

    If you have a simple test case, file a bug at bugs.adobe.com/jira

  • Local files lost

    Hey, Since a few months, Spotify don't show and don't play my local files. The scan ist running and it shows up to 10.000 songs, but don't display them. I've already refresh the folder in the option. It scans every time, but don't show the songs. Does it maybe depends on to many songs in the folder? Greetings from Germany! :-)

    Hiya:
    Have you tried a reinstallation? Don't worry - you won't loose anything.
    ~Joe

  • Apple Mail Hotmail local DB lost

    Hi
    My problem is about Apple Mail and my hotmail account:
    Recently i've upgraded Lion to 10.7.3, i don't know if this is tha cause but when i try to launch Mail, it shows the wizard for configuring a new account...
    and where are my emails???
    what can i do?

    It is strange, indeed. I'm running here 8 mail accounts in Mail, some Gmail and 2 with private ISP's, all IMAP, and one corporate MS Exchange account, all without the slightest problem on my side, also in 10.8.2.
    Since it's Exchange and nothing will get lost, I'd strongly recommend to back up mail folders on your Mac under the account, then delete the troublesome mail account entirely, shut down mail, reboot or at least log out and back in, then set up the mail account from scratch. It works well automatically, usually, but go carefully through the options, e.g. ports, server-side mail folders etc., to make sure Mail actually has access to wherever the mails are on the server. It should work absolutely fine for you then, too.

  • After transition to iCloud, all local contacts lost

    Following a 'Bumpy" transition from MobileMe to iCloud (a lot of duplication removal and clean-up), I notice the the Address Book (unbeknownst to me) was showing iCloud as the Default Account.  When I select "On My Mac"/"All on My Mac", it appears as totally empty.  The 729 contacts in the iCloud Address Book stays in 'sync with the 729 contacts on my iPhone, (I added and deleted, just to make sure).  iCloud preferences seems to be setup correctly (iCal is working fine).  In Address Book Preferences, the Primary (top acct) is showing iCloud with and enabled check-box; the sendonday acct is showing On My Mac, but it has no Enable check-box - just two for syncronizing with Yahoo and Google (both un-checked).  I even disabled the iCloud acct and tried to import a recent .abbu fille into the 'On My Mac Address Book' with no affect.  Any pointers would be appreciated.
    Jim C.

    at that time i think you select all thats why all were erased why do u create another account u can use 1google account.and try to recover or try to serch your contcat using PC companion there is a contact option and try it
    Do not forget to give kudosand to select the correct answer 

  • Using ResourceBundle and Locale in an Applet

    hello,
    i worked out a little application to use with multilanguage support.
    i wrote two classes so i can start the application within a jar file located on my computer and anotherone to launch it as an applet...
    for development i use Eclipse; when i try to run it in eclipse everything works fine (although i limit the access of the applet!)
    when i try to run the applet in IE i get the error message:
    java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)i did not use the function "System.getProperty("user.dir")" in MY code which is referred!
    so i guess its one of the included packages:
    ResourceBundle | Locale
    how can i solve this problem as its working in the limited access applet in eclipse??
    thanks in advance

    note: i do load the .properties file from the JAR package, not from hdd!
    here is my code
    import java.util.Locale;
    import java.util.ResourceBundle;
    public class Xlocale {
         private Locale locale = Locale.ENGLISH;
         private ResourceBundle thisLocaleRB;
         public Xlocale(String aXlocaleName, String aLocale) {
              setLocale(getLocale(aLocale)); //if you leave this line it won't work *hmm?*
              if (thisLocaleRB == null || getLocale() != thisLocaleRB.getLocale()) {
                   try {
                        thisLocaleRB = ResourceBundle.getBundle(aXlocaleName, getLocale());
                   } catch (Exception e) {
                        //System.err.println(e.getLocalizedMessage()+" ["+System.getProperty("user.dir")+"\\"+aXlocaleName+"_"+getLocale()+".properties]\n");
         public String getString(String key, String dv) {
              String val = thisLocaleRB.getString(key);
              if (val == null)
                   return dv;
              else
                   return val;
         public void setLocale(Locale l) {
              this.locale = l;
         public Locale getLocale() {
              return this.locale == null ? Locale.ENGLISH : locale;
        public static Locale getLocale(String loc)
            if(loc!=null && loc.length()>0)
                return new Locale(loc);
            else
                return Locale.ENGLISH;
    }

  • Problem in converting the unicode to local language

    Hi all,
    i am trying to convert unicode char to my local language and print it on label but i am not getting the proper output.
    the code is given below
    package test;
    import java.util.*;
    import java.awt.*;
    public class KanProp extends Frame{
    Locale lcl;
    ResourceBundle resbdl;
    Label lbl;
    public KanProp(){
              setLayout(null);
              setSize(400,400);
              lcl =new Locale("kn","IN");
              resbdl=ResourceBundle.getBundle("LocalStrings_kn",lcl);
              String str=resbdl.getString("Name");
              lbl=new Label();
              lbl.setFont(new Font("JanaKannada",Font.BOLD,24));
              lbl.setBounds(0,100,100,20);
              lbl.setText(str);
              add(lbl);
              setVisible(true);
       static public void main(String[] args) {
          new KanProp();
       } // main
    } // classand i am reading a key (ie Name) from the .properties file
    can any one please give me the solution?

    1. Square box means font does not have a glyph to render your char, or
    2. Label is not a lightweight component and may strongly depend on OS - it may result in problems with changing font or using non-OS native characters. Try move to Swing and use JLabel.
    3. Try to hardcode unicode text in your source - use editor which supports UTF-8 format and add -encoding UTF-8 in javac command line. This will show if there is any problem with reading resource.

  • Problem with ResourceBundle in Jar

    Hi,
    I've written the following class which works perfectly in my program but not when used in the same code but distributed as a Jar file.
    In this case, only the default locale is used on a "Messages.getString" call, even if I swith the local to English...
    I've read that there was a "bug" in the j2sdk1.4.2_05 and I'm using the j2sdk1.4.2_06.
    Do you have any idea ?
    Thanks,
    Marc.
    package com.oxiane.marketing.IHM;
    import java.util.Locale;
    import java.util.MissingResourceException;
    import java.util.ResourceBundle;
    * Classe servant � g�rer les langues Anglaise et Fran�aise pour
    * l'interface.
    public class Messages {
         private static final String BUNDLE_NAME = "Messages" ;
         private static ResourceBundle RES_BUNDLE_FR = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault());
         private static ResourceBundle RES_BUNDLE_EN = ResourceBundle.getBundle(BUNDLE_NAME, Locale.ENGLISH);
            public static String getString(String msg){
                 try {
                      if (Locale.getDefault().getLanguage() == "fr")
                           return RES_BUNDLE_FR.getString(msg);
                      else
                           return RES_BUNDLE_EN.getString(msg);
                 catch (MissingResourceException e){
                      System.out.println(e.getMessage());
                      return "";
         public static void setLocale(Locale loc){
              Locale.setDefault(loc);
         public static Locale getLocale(){
              return Locale.getDefault();
    }

    You should take care of the directory structure according to the package structure.
    I for example have this jar:
    C:\source\java\ebank2_util\smsunlock>unzip -l pro-ebank_sms_unlock.jar
    Archive:  pro-ebank_sms_unlock.jar
    Length    Date    Time    Name
          0  10-28-05  17:27   hu/
          0  10-28-05  17:27   hu/khb/
          0  10-28-05  18:17   hu/khb/smsunlock/
        256  11-07-05  16:33   hu/khb/smsunlock/DButils$MySQLException.class
       4229  11-07-05  16:33   hu/khb/smsunlock/DButils.class
       1700  11-07-05  16:33   hu/khb/smsunlock/GUI$1.class
       2318  11-07-05  16:33   hu/khb/smsunlock/GUI$2.class
        988  11-07-05  16:33   hu/khb/smsunlock/GUI$3.class
       1402  11-07-05  16:33   hu/khb/smsunlock/GUI$mywl.class
       5630  11-07-05  16:33   hu/khb/smsunlock/GUI.class
        818  11-07-05  16:33   hu/khb/smsunlock/LimitedLength_TextField.class
       2452  11-07-05  16:33   hu/khb/smsunlock/Main.class
        900  11-07-05  16:33   hu/khb/smsunlock/MyInputStream.class
          0  11-07-05  16:33   META-INF/
         98  10-27-05  15:53   META-INF/manifest.mf
         90  11-07-05  16:33   hu/khb/smsunlock/properties
      20881                    16 filesAnd the resource is loaded like this from hu.khb.smsu.Main:
    InputStream is = new MyInputStream( Main.class.getResourceAsStream( "properties" ) );

  • Maintaining default locale in multi-lingual application

    Hello,
    I have a multi-lingual application where the language can be changed at runtime.
    To make the following code work properly, the default locale has to be set each
    time the language changes. Why?
    Since I need to check sometimes the platforms original locale (I do this with
    "Locale.getDefault()"), I am looking for a way not to change the default locale,
    but still to change the resourceBundle.
    In the API I read under "ResourceBundle, Cache Management" that the bundles are cached. Is this the reason why redefining the resourceBundle has no effect? And if yes, how can it be avoided?
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    public class Y extends JFrame {
      boolean toggle;
      Locale currentLocale;
      JButton b;
      ResourceBundle languageBundle;
      String country, userLanguage;
      public Y() {
        setSize(300,300);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        Container cp= getContentPane();
        b= new JButton();
        b.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
         toggle= !toggle;
         if (toggle)
           country= "DE";
         else
           country= "GB";
         setUserLanguage(country);
        cp.add(b, BorderLayout.SOUTH);
        setUserLanguage("GB");
        setVisible(true);
      public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
         new Y();
      void setUserLanguage(String country) {
        if (country.equals("DE"))
          userLanguage= "de";
        else
          userLanguage= "en";
        currentLocale = new Locale(userLanguage, country);
    //    System.out.println(currentLocale); // The locale changes ...
    //    Locale.setDefault(currentLocale); // Remove comment slashes and it works.
    //    languageBundle.clearCache(); // No effect.
        languageBundle = ResourceBundle.getBundle("MyBundle",currentLocale);
        System.out.println(languageBundle); // ... but the resourceBundle does not change.
        b.setText(languageBundle.getString("ButtonText"));
    The resource bundle files:
    MyBundle.properties
    ButtonText= Just a button
    MyBundle_de_DE.properties
    ButtonText= Nur ein KnopfEdited by: Joerg22 on 18.08.2008 13:26

    What's your default locale? If your default locale is de_DE, that's the expected behavior. The reason for it is the fallback mechanism searches default locale's bundle before falls back to the base bundle, i.e., in case of searching en_GB bundle, the search order is:
    en_GB
    en
    de_DE
    de
    (base)
    So, it will choose MyBundles_de_DE.
    If you do not want this default locale fallback, you can specify ResourceBundle.Control instance, which is returned from ResourceBundle.Control.getNoFallbackControl() method, in your getBundle() call. Or if you do not use JDK6, you could copy the base bundle to MyBundles_en, which is ugly but should work.
    Naoto
    Edited by: naoto on Aug 18, 2008 1:05 PM

  • ResourceBundle loading algorithm.

    Hi folks,
    I do have a problem/question with the resource bundle loading algorithm.
    Here is my setup:
    I have written a taglib which retrieves the user locale from the request and returns a message in the user's language, if the resource bundle does not exist, English text should be returned.
    Well, here is the problem:
    Say the user sends pt_BR
    JVM's locale is de_DE (Locale.getDefault())
    The taglib is publicly available so I have no influence on the server/JVM locale.
    Available are:
    bundle.properties (contains English text)
    bundle_de.properties (German strings)
    Well, what happens is that no bundle_pt_br.properties is going to be found and the user receives the bundle_de.properties content.
    The outcome is that the Portuguese speaker sees messages in German which is absolutely useless and undesired.
    Is this really intended to happen in this algorithm, if yes, why? How can this be bridged?
    The only solution I see is to check the bundle's locale against the locale I wanted to load.
    Thanks,
    Mike

    I've checked the behavior from JDK 1.1 to JDK 7. All behaved the same: fallback to the de locale. IIRC, the ResourceBundle API doc was rewritten to reflect the actual behavior in JDK 1.3. But the behavior didn't change.
    I don't know reasons why ResourceBundle.getBudle() was designed to fallback to the default locale, but a number of developers had complained about the behavior. That was one of the reasons that ResourceBundle.Control was introduced in JDK 6.
    As Piet pointed out, you can subclass ResourceBundle.Control if you can use JDK6. There is convenience method ResourceBundle.Control.getNoFallbackControl() that returns a ResourceBundle.Control with which getBundle() doesn't fallback to the default locale. If you are using JDK 5.0 or earlier, the workaround would be to provide empty resource bundles for unsupported languages, like bundle_pt.properties.
    HTH
    Masayoshi

Maybe you are looking for