9 Replies Latest reply on Oct 10, 2003 10:14 AM by aalmero

    ResourceBundle

    micael

      I am trying to get init() in a servlet to read an actions.properties file with:

      ResourceBundle bundle = ResourceBundle.getBundle("actions");

      and the properties file is placed at

      webapps/classes/actions.properties

      Nonetheless, I get a "can't find bundle" servlet exception. I have the classpath properly set. Anyone know what I am not doing right? Any assistance appreciated.

        • 1. Re: ResourceBundle
          neillamoureux

          I have no problem with using a resource bundle, although I place it in war file under WEB-INF/classes/. The war file is added to my ear file, which is then placed in JBoss' deploy directory. However, if you want to still place it under webapps, try webapps/"yourServletContext"/WEB-INF/classes/

          • 2. Re: ResourceBundle
            jperson

            I am having the same problem..I have tried putting the ".properties" file everywhere and yet no luck

            • 3. Re: ResourceBundle
              hairylemon

              Has anyone managed to find out what the problem is here? I have a properties file and I know I have its directory set up in the classpath but I still get the MissingResource exception.

              • 4. Re: ResourceBundle
                micael

                I finally solved this problem by putting the properties files at WEB-INF/classes/props.properties.

                But, I don't know why that should make any difference.

                • 5. Re: ResourceBundle
                  hairylemon

                  I don't know either. That web-inf directory is used for web servers isn't it? I'm just running a straightforward GUI application which needs to access a properties file. It looks like it needs more than simply being in a classpath directory but whatever it is, I have no clue.

                  • 6. Re: ResourceBundle
                    dojeff

                    I met the same problem on JBoss3.0.4_Tomcat4.0.6.
                    I follow your way to put all of the properties files under WEB-INF/classes/props.properties and use messages = ResourceBundle.getBundle("MessagesBundle"); in JSP page, then I still get error message: "org.apache.catalina.jsp_file : /Error.jsp
                    javax.servlet.jsp.jspException : java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key"




                    • 7. Re: ResourceBundle
                      raja05

                      If ur .properties is definitely in ur classpath, try this

                      ResourceBundle bundle = ResourceBundle..getBundle(, , getClass().getClassLoader());

                      -Raj

                      • 8. Re: ResourceBundle
                        aalmero

                        I tried to use the code below but i still got the same error when using it inside a java class. but when i tried it using in a jsp file it worked.

                        need help on this one. thanks

                        alex

                        • 9. Re: ResourceBundle
                          aalmero

                          I finally figured it out.

                          ENV: win2000,jboss3.2.1,tomcat4.1.24

                          i just moved my *.properties on <JBOSS_HOME>/server/default/conf and the following codes below worked.

                          ResourceBundle rb = ResourceBundle.getBundle("MyPropeties");

                          rb.getString("db");
                          ....

                          alex