Resource Bundle and EJB


EJB programming & troubleshooting: Resource Bundle and EJB

  1. Resource Bundle and EJB (6 messages)

    Has anyone tried successfully loading a ResourceBundle properties file from within a EJB? Any help appreciated. Thanks


    Threaded Messages (6)

  2. Resource Bundle and EJB[ Go to top ]

    It's very easy. Just make sure the bundle is in the EJB classloader's classpath.
  3. Resource Bundle and EJB[ Go to top ]

    If you're using ResourceBundle to contain properties for an EJB, I would recommend using the EJB's deployment descriptor (ejb-jar.xml) instead. The ejb-jar.xml file supports the <env-entry> element, which you can use to store name-value pairs that represent properties like this:


    From your EJB bean class, you obtain the property like this:

    InitialContext ic = new InitialContext();
    String logDirectory = (String) ic.lookup("java:comp/env/logPath");

    Hope it helps!

  4. Resource Bundle and EJB[ Go to top ]

    A EJB DD env entry can only be accessed by a single EJB. A resource bundle can be used by all EJB's and web app in the same .ear.
  5. Resource Bundle and EJB[ Go to top ]

    Hello Eric and SAF,
    Thanks for you replies. I need to localize messages based on user locale. Hence the need for ResourceBundle. Have you tried the same with JBoss? Thanks
  6. Resource Bundle and EJB[ Go to top ]

    To explain further, my file is in the same place as Bean impl file. So I jarred them up. But the Server cannot seem to find it. Do I have to explicitly add it to class path? Thanks
  7. Resource Bundle and EJB[ Go to top ]

    If the property file is in your ejb jar file, then I dont see why you're ejb is having problems finding it.

    Try placing the property file in your EAR root directory and reference the file from the ejb's Manifest file