Why jre makes unnecessary trips to server for getting properties file

Hi,
I'm using ResourceBundle.getBundle("myresource") method for loading the resourcebundle. I have placed my myresource.properties file in the jar which loaded, when UI getting loaded. But I could see from the java console(by entering 5), that java-plugin makes several trips to server, though I have the file in the client loaded jar file. How can I avoid it. Thanks for any help.
The search goes as follows:
Opening http://<servername>:7001/myresource.class
Connecting http://<servername>:7001/myresource.class with no proxy
Connecting http://<servername>:7001/myresource.class with cookie "JSESSIONID=APBnBCd2y8mJRQgGM9GqzXAT197iMQv7SaM9QORKg5mxvyp1PRKh!-1116598258"
Opening http://<servername>:7001/myresource_en.class
Connecting http://<servername>:7001/myresource_en.class with no proxy
Connecting http://<servername>:7001/myresource_en.class with cookie "JSESSIONID=APBnBCd2y8mJRQgGM9GqzXAT197iMQv7SaM9QORKg5mxvyp1PRKh!-1116598258"
Opening http://<servername>:7001/myresource_en.properties
Connecting http://<servername>:7001/myresource_en.properties with no proxy
Connecting http://<servername>:7001/myresource_en.properties with cookie "JSESSIONID=APBnBCd2y8mJRQgGM9GqzXAT197iMQv7SaM9QORKg5mxvyp1PRKh!-1116598258"
Opening http://<servername>:7001/myresource_en_US.class
Connecting http://<servername>:7001/myresource_en_US.class with no proxy
Connecting http://<servername>:7001/myresource_en_US.class with cookie "JSESSIONID=APBnBCd2y8mJRQgGM9GqzXAT197iMQv7SaM9QORKg5mxvyp1PRKh!-1116598258"
Thanks

The reason the unnecessary trips are being made is that the ResourceBundle is using the default class loader to find the resource files. When a resource can't be found in the jar file, it will send a request to the server to see if it exists there. For the locale "en_US" and the bundle name "myresource", the ResourceBundle will attempt to load all of the following resources:
   myresource.class
   myresource.properties
   myresource_en.class
   myresource_en.properties
   myresource_en_US.class
   myresource_en_US.propertiesSince, you only had "myresource.properties" in your jar file, the ClassLoader attempted to find the other resources on the server.
The following code can be used to create a resource bundle that uses a special classloader that only searches the included jar or zip files. This only works on 1.2 or greater JVMs.
   public ResourceBundle getResourceBundle(String bundleName) {
      ClassLoader rcl = null;
      Locale l = Locale.getDefault();
      ClassLoader cl = this.getClass().getClassLoader();
      if (cl instanceof java.net.URLClassLoader) {
         java.net.URLClassLoader ucl = (java.net.URLClassLoader)cl;
         URL[] urls = ucl.getURLs();
         ArrayList jarUrls = new ArrayList();
         for (int i=0; i<urls.length; i++) {
            String path = urls.getPath();
if ((path.endsWith(".jar")) || (path.endsWith(".JAR")) ||
(path.endsWith(".zip")) || (path.endsWith(".ZIP")))
jarUrls.add(urls[i]);
URL[] newUrls = new URL[jarUrls.size()];
jarUrls.toArray(newUrls);
rcl = java.net.URLClassLoader.newInstance(newUrls, null);
} else {
rcl = cl;
DiagUtils.log("Resource bundle: " + bundleName + " initializing...");
ResourceBundle rb = ResourceBundle.getBundle(bundleName, l, rcl);
DiagUtils.log("Resource bundle: " + bundleName + " initialized.");
return rb;
The basic idea behind this code is to create a new URLClassLoader which only contains URLs that end with ".jar" or ".zip". The parent classloader must be set to null in the newInstance method.
This will not work on the MSJVM because URLClassLoader was introduced with JDK 1.2.
I hope this helps.
-jonp

Similar Messages

  • Classpath root for locating properties file?

    I'm trying to read a property file from a pluggable Reports destination. I've tried placing it in the domain root and in the domain lib folder (I'm sure it was picked up there in a previous release) but I can't appear to find it.
    What is a general classpath root that could be used for storing properties files in?
    Thanks in advance,
    Nik

    Open your %DOMAIN_HOME%/server/AdminServer/logs/AdminServer.log and search for java.class.path.
    You'll see all classpath roots available, I'm using %DOMAIN_HOME%/config/soa-infra.
    Cheers,
    Vlad

  • Why not make character bigger in NOKIA for prebyop...

    you know it's difficult for a Chinese to write English, but I want to try for my suggestion to NOKIA! Nokia is now on a rough situation because as I know she lose  sales volume to APPLE, HTC. China is the biggest market of NOKIA, and also there is a large number of  presbyopia. Presbyopia, they have the strongest purchasing power, they want to be creditable by showing their elegant cell phone.   but they can't see clearly in their NOKIA because character font is so small to them. So they give up NOKIA! Why not make NOKIA bigger? I mean the character. At the same time, NOKIA can also research and develope a software to enlarge the character in all the NOKIA series.

    hi seimei,
    <blockquote>There is no default search engine. That is a flawed concept. Which engine I use depends on what I am searching.</blockquote>
    the new search interface in firefox 34 and upwards does address exactly this situation and is optimized for that scenario - you type your search term and select the search engine you want to go it to & you're done (if you want do do a search with the default engine just hit enter). in the old interface you needed at least one more click for that action...
    please also note that for the moment at least it's still possible to change back to the old interface in firefox 34 and above:
    enter '''about:config''' into the firefox address bar (confirm the info message in case it shows up) & search for the preference named '''browser.search.showOneOffButtons'''. double-click it and change its value to '''false''' (this will take a restart of the browser to have an effect).

  • How to give Path for a properties file

    Hi,
    I am using a SQL.properties file to load all my SQL statements to my EJB JDBC prepared Statement. I have placed the SQL.properties file in com.company.sql package. I have another SQL class in the same package which is loading the SQL.properties file to cache for future use. I am using the path as "SQL.properties" (the file name straight ) in the SQL class to access the properties file.
    I am using Sun App Server 7. To get access to this file I need to copy the SQL.properties file to the config directory of the app server instance. Otherwise it is not able to locate the file. I don't want to put the properties file in the config directory of the app server instance. Please help me, what path I have to give to access the file from the package itself, rather from the config directory of server instance.
    I think , some one who is doing localization can help me out here. They have to put the localized properties file to access the text out of it. Please help me. Thanks in advance.
    Thanks
    Amit

    You can use ResourceBundle class to load this properties file from the classpath:
    ResourceBundle props = null;
    props = ResourceBundle.getBundle("com.company.sql.SQL");

  • How to set Path for a properties file

    Hi,
    I am using a SQL.properties file to load all my SQL statements to my EJB JDBC prepared Statement. I have placed the SQL.properties file in com.company.sql package. I have another SQL class in the same package which is loading the SQL.properties file to cache for future use. I am using the path as "SQL.properties" (the file name straight ) in the SQL class to access the properties file.
    I am using Sun App Server 7. To get access to this file I need to copy the SQL.properties file to the config directory of the app server instance. Otherwise it is not able to locate the file. I don't want to put the properties file in the config directory of the app server instance. Please help me, what path I have to give to access the file from the package itself, rather from the config directory of server instance.
    I think , some one who is doing localization can help me out here. They have to put the localized properties file to access the text out of it. Please help me. Thanks in advance.
    Thanks
    Amit

    I am using the propeties file to get the SQL statements. I have all the SQL query statement in the properties file. I am creating a preparedstatement after getting the statement from the properties file with the id like we do in ResourceBundle. If I keep the properties file in the config directory of the Sun App Server instance , then it is working fine. But If I don't keep it there, then it is giving me a file not found exception.
    My SQL class which is accessing the properties file are in same package (com.company.sql). But still it is not able to find the file. As suggested by you, I tried it by giving the path as com.company.sql.SQL. Still it did not found the file. The file is there inside the WEB-INF/classess/com/company/sql/.
    Thanks
    Amit

  • Tool for generating properties files

    Hello Experties,
    I am wondering is there a tool or program for SAP to get SAP fields screen names from SAP backend for diffrent languages and generat the properties files?
    for java uwl or webdynpro they are all the same properties file.
    thanks

    WebDynpro i18n is done by .xlf files. Its an standard (http://en.wikipedia.org/wiki/Xliff) and there are some OSS editors available, just google xlf editor.Or check this one: http://okapi.opentag.com/applications.html#rainbow
    The Idea is, that you give your xlf files to the translator and safe the results with a suffix representing the language (_de.xlf for german).
    Hope this helps.

  • I cannot make backup on BlackBerry server for my Q10

    Hello, I need somebody to advise why my Q 10 cannot be backed up on Blackberry server!. does this related to my country location? Kuwait!

    ziadadel wrote:
    the legacy system enable me to back up my mobile everyday automaticly, but this is not
    Yes, to BlackBerry Protect. But, as I said, BB Protect is not, IMHO, to be considered a FULL AND COMPLETE backup. For legacy, only when it was supplemented by other processes could a FULL AND COMPLETE backup be accomplished.
    But, with BB10, lacking the Protect component does not mean that daily backups cannot be achieved. They just must be achieved in a different manner (e.g., via LINK, by using an OTA service to keep Contacts and Calendar synced, etc.).
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Needs to know why firefox did not send a request for appcache manifest file declared in the html manifest="url" and how to fix it?

    I created an HTML5 appcache app as follow:
    <!DOCTYPE html>
    <html manifest="url.manifest">
    <head>
    </head>
    <body>
    </body>
    Upon onload() event, I made several AJAX calls (POST) to the servers to load the data for the first time and they all done via HTTPS. I've inspected the servers' access log and I did not see the request for url.manifest and the loading of the appcache fails with an error (no details provided).
    Chrome is working fine with current setup and here is the content of my manifest:
    CACHE MANIFEST
    CACHE:
    /images/flower.gif

    This forum answers many webdev questions, but I think yours calls for a higher level of expertise. You may want to try the [http://forums.mozillazine.org/viewforum.php?f=25 mozillaZine Web Development board]. It is an unofficial forum with separate registration.

  • How do I make Pages my default program for opening doc files

    Currently TextEdit is the default program to open doc files that I download from emails. Now that I've installed iWork 08 I would like Pages to be the default program. Thanks!

    Right-click any .DOC file and select Get Info. Then choose Pages as the open with application and select "Change For All. Pages is now your default app for .DOCs.

  • Recently opening an HTML file on my computer makes firefox attempt a search for the entire file name in the search engine online, how to do i correct that?

    when opening an HTML file recently my Firefox automatically opens up a yahoo search screen and the file, the entire file name and route for the file is searched for online. I don't even use Yahoo Search i use Google but that doesn't mater have to open the file manually with searching it on on the open screen to read it because it's trying to search for it online instead of reading it from where i clicked on it.
    I.E.
    file:///F:/Reading/II.html
    would try to search
    https://us.search.yahoo.com/yhs/search?hspart=aztec&hsimp=yhs-default&type=derr_100_476&p=file%3A%2F%2F%2FF%3A%2FReading%2Fhtml&rnd=737753354&param1=sid%3D476%3Aaid%3D100%3Aver%3D15005%3Atm%3D264%3Asrc%3Dderr%3Alng%3Den%3Aitype%3Da%3Auip%3D1124173343
    I have no idea what the
    &rnd=737753354&param1=sid%3D476%3Aaid%3D100%3Aver%3D15005%3Atm%3D264%3Asrc%3Dderr%3Alng%3Den%3Aitype%3Da%3Auip%3D1124173343
    is for but it's never done this before.

    Please read this article about restoring bookmarks:
    http://kb.mozillazine.org/Lost_bookmarks
    As far as your passwords are concerned, I don't think there's anything you can do. But for the future, you can use the following add-ons to avoid any future loss:
    https://addons.mozilla.org/en-US/firefox/addon/2848/
    or
    http://www.xmarks.com/
    Both are good.
    And a simple way to import your bookmarks (since you already saved it on your desktop as html) is:
    Bookmarks / Organized Bookmarks / Import and Export
    Good luck.

  • How to make PremPro stop asking me for a video file

    I have never been able to figure this out and I know there must be a simple solution.
    I have a project and there was a video I wanted to use, Unfortunately, it ALWAYS crashed Premiere Pro. So I cleared it out of the project and deleted the file off my coputer.
    Yet every time I open that project, I get a popup asking me "Where is the File "Name of File'?"
    This is maddening. How do I stop this?

    No, I have not tried that with this project. I've just been dealing with it. Wish I knew a way to fix this but such is life.
    Thanks for the help, everybody. It is what it is. 

  • Why won't premiere CS6 play audio for imported AVCHD files on my window 7 laptop?

    After I've imported the AVCHD file the video plays just fine, but the audio isn't there at all. I still have the original video files on my SD card, I've tried Wondershare to convert the file, but the video became corrupted. Any tips?
    Thanks!

    &therigbys wrote:
    I installed Premier Pro CS6 last week, so I believe it's the most updated version.
    Not necessarily, go to Help > Updates. We're on Premiere Pro CS6 (6.0.3) in Windows now.
    therigbys wrote:
    I was running Spotify, Chrome, & Microsoft Word when I imported the footage.
    Uninstall Spotify and see if that helps. I've heard about some crazy things related to that app. Better to run all these apps on a cheap secondary computer or iPad.

  • In the Begining it's Flat Files - Best Practice for Getting Flat File Data

    I probably should have posed this question here before I delved into writing Java to get data for reports, but better late than never.
    Our ERP is written in COBOL. We have a third party ODBC which allows us to access data using a version of SQL. I have several Java sources compiled in my database that access the data and return something relevant. The Java sources are written in a procedural style rather than taking advantage of object oriented programming with attributes and methods.
    Now that I am becoming more comfortable with the Java language, I would greatly appreciate any feedback as to best practices for incorporating Java into my database.
    My guess is that it would be helpful to model the ERP "tables" with Java classes that would have attributes, which correspond to the fields, and methods to return the attributes in an appropriate way. Does that sound reasonable? If so, is there a way to automate the task of modeling the tables? If not reasonable, what would you recommend?
    Thanks,
    Gregory

    Brother wrote:
    I probably should have posed this question here before I delved into writing Java to get data for reports, but better late than never.
    Our ERP is written in COBOL. We have a third party ODBC which allows us to access data using a version of SQL. I have several Java sources compiled in my database that access the data and return something relevant. The Java sources are written in a procedural style rather than taking advantage of object oriented programming with attributes and methods.
    OO is a choice not a mandate. Using Java in a procedural way is certainly not ideal but given that it is existing code I would look more into whether is well written procedural code rather than looking at the lack of OO.
    Now that I am becoming more comfortable with the Java language, I would greatly appreciate any feedback as to best practices for incorporating Java into my database.
    My guess is that it would be helpful to model the ERP "tables" with Java classes that would have attributes, which correspond to the fields, and methods to return the attributes in an appropriate way. Does that sound reasonable? If so, is there a way to automate the task of modeling the tables? If not reasonable, what would you recommend?Normally you create a data model driven by business need. You then implement using whatever means seem expedient in terms of other business constraints to closely model that data model.
    It is often the case that there is a strong correlation between data models and tables but certainly in my experience it is rare when there are not other needs driven by the data model (such as how foreign keys and link tables are implemented and used.)

  • FM for getting teh file name with path

    Hi guys,
    Is there an fm getting the file name with path given the physical path and file name? Thanks!

    Hi Mark,
    Function Module WS_FILENAME_GET is obsolete, dont use it.
    Use the Method file_open_dialog of  class cl_gui_frontend_services as given below.
    DATA:
        lt_filetable TYPE filetable,
        lf_rc        TYPE i,
        lv_filename(50) TYPE c,
        lv_fileext(3) TYPE c,
        ls_file TYPE file_table,
        lv_file TYPE localfile,
        lv_title TYPE string.
      lv_title = sy-title.
      lv_progname = sy-cprog.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = lv_title
          file_filter             = '*.txt'
          multiselection          = abap_false
        CHANGING
          file_table              = lt_filetable
          rc                      = lf_rc
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                   DISPLAY LIKE 'E'
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        EXIT.
      ENDIF.
    * Number of selected filed must be equal to one.
      CHECK lf_rc = 1.
    * Access selected file
      READ TABLE lt_filetable INTO ls_file INDEX 1.
      CHECK sy-subrc = 0.
      lv_file = ls_file-filename.
      SPLIT lv_file AT '.' INTO lv_filename lv_fileext.
    Revert back if you need clarifications.
    Regards
    Karthik D

  • File server for school LAN--unable to get Open Directory working right

    I've been following the tutorials on wazmac.com for configuring an OSX 10.6 server for local network file sharing.
    Server IP address is 192.168.1.99.
    FQDN is oltserver.ourladyoftepeyac
    AFP, DNS, and Open Directory are configured, supposedly correctly.
    What works:
    Resolving the domain name to the server's IP address and vice-versa on Network Utility Lookup while on the server.
    On client computers, under Accounts, I can bind to the IP address and I can bind to "oltserver.local".
    After binding and restarting, I get a logon screen that shows the available users I have created in Workgroup Manager.
    What doesn't work:
    Cannot resolve the domain name to the server's IP address and vice-versa on Network Utility Lookup while on client machines.
    On client computers, under Accounts, I cannot bind to the FQDN, oltserver.ourladyoftepeyac. Error: Could not resolve the address (2200).
    When trying to log on to a network account from a client, it fails. "Cannot log in because an error occurred."
    There must be a problem with the settings for my DNS service. But unfortunately the wazmac guide doesn't give a lot of troubleshooting advice.
    Any help would be appreciated. Here are bunches of settings screenshots.

    That's terrific! I am almost there.
    What I did:
    I followed your advice on the domain name and renamed it ourladyoftepeyac.lan. Screenshot.
    Then (what probably made a big difference), I went into the network settings for the client Macs and removed their incorrect manual settings for DNS servers. This gave them the correct DNS servers! Screenshot.
    This allowed the Network Utility on client machines to correctly resolve the server's IP address with the domain name! Screenshot.
    Aaaaand it solved the problem with previously being unable to bind the client mac to the Open Directory server. Screenshot.
    But:
    After all of that, the clients still aren't logging in. So disappointing. It's unbelievable how unhelpful the error message is, too. "Logging in to the account failed because an error occurred."
    I can't understand why this is. AFP is active and set to allow guests to log in. Unfortunately, with all the help you've given, I don't have any clues left as to why the clients aren't logging on.

Maybe you are looking for