java.util.ResourceBundle cannot find .properties files

1,426 views
Skip to first unread message

Jacek

unread,
Feb 21, 2013, 11:45:26 AM2/21/13
to ra...@googlegroups.com
Hello all!

I'm in a project of adapting an ACF8 application to Railo, and got stuck in a code block which uses "java.util.ResourceBundle" directly, assuming that all .properties localized texts files are located inside a classpath. In CF there was an entry in JVM config, pointing to a directory with the .properties files, which additionally are organized in subfolders.

In Railo, I was trying adding symbolic links and copying physical dirs into /WEB-INF/railo/lib and WEB-INF/lib folders, but still get this error "java.util.MissingResourceException [...] Can't find bundle for base name [...], locale [...] at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)"

The code (simplified):
Variables.instance.rB=createObject("java","java.util.ResourceBundle");
thisBundle=Variables.instance.rB.getBundle(arguments.rbFile,thisLocale);

I'm on Tomcat 6 and linux, using Railo 4.0.3.006 final. Railo was configured on a similar basis to this guide: http://jamesconstable.co.uk/web-development/installing-railo-3-on-tomcat-6-via-apache-2-on-ubuntu-804/ (not using the Railo installer)

I was wondering if anyone here has experienced a similar problem, and was able to resolve it. Any observations and suggestions will be greatly appreciated.

Igal @ getRailo.org

unread,
Feb 21, 2013, 11:59:32 AM2/21/13
to ra...@googlegroups.com
I didn't read your whole post, but:

you can try to add paths to the "common.loader" property in
{Tomcat}/conf/catalina.properties


Igal
> greatly appreciated. --
> You received this message because you are subscribed to the Google
> Groups "Railo" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to railo+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Jacek

unread,
Feb 21, 2013, 12:04:26 PM2/21/13
to ra...@googlegroups.com
Thank you Igal for your fast response. I was thinking of that solution too, but I guess it could bring some troubles: on the same server there are more applications, some of them using the same way of calling i18n resources  Many of those dirs/files have the same names. What I'm guessing is that those resources could get "mixed up" between applications...

Igal @ getRailo.org

unread,
Feb 21, 2013, 12:11:36 PM2/21/13
to ra...@googlegroups.com
yes, that is a concern under those circumstances.

in general if you need to make the libs available to Tomcat you will put it in /WEB-INF/lib and if you need it in Railo you will put it in /WEB-INF/railo/lib so I'm not sure why that didn't work for you.

but now that I think of it -- you placed the .properties file in the /lib folder?  if that's the case -- try to put the .properties file in a .jar file (really a zip archive with .jar extension) and then put that .jar in one of those lib folders.  chances are that the lib folders have a *.jar filter when reading their contents.


Igal

Jacek

unread,
Feb 21, 2013, 3:36:15 PM2/21/13
to ra...@googlegroups.com
Thank you again for your answer. I tried your suggestions. I put the .properties files as well as entire i18n folder alone, and zip-compressed as .jar in both /lib and /railo/lib folders, and no luck.

The strangest thing is that in Railo admin those files are visible:

Classpath
/usr/share/tomcat6/bin/bootstrap.jar
[path]/WEB-INF/railo/classes
[path]/WEB-INF/railo/lib/i18n.jar
[path]/WEB-INF/railo/lib/i18n

Maybe there is some kind of filter omitting the .properties files, as you suggested.

For now the only thing I can think of is to try java.util.PropertyResourceBundle instead of java.util.ResourceBundle, which means rewriting more code :)

Igal @ getRailo.org

unread,
Feb 21, 2013, 3:45:27 PM2/21/13
to ra...@googlegroups.com
the only things I can think of are:

1) try the classes folders for the .properties files, i.e. /WEB-INF/classes or /WEB-INF/railo/classes

2) if you packed the I18N folders into JARs then make sure that the packages of the classes match the folder structure inside the jars.


Igal

Jacek

unread,
Feb 21, 2013, 6:25:07 PM2/21/13
to ra...@googlegroups.com
Copied symbolic links, physical directories and files to all possible locations of Railo - still no luck.

But when desperately I've defined a classpath in "common.loader" of "catalina,properties" (just a path to i18n folder in application), the things started to work. I guess there must be some error in a way I configure Railo, at least this is what occurs to me at this moment. As I pointed before, I cannot left this configuration due to conflicts with other applications. Will continue to struggle with this tomorrow.

Thank you again for your help, maybe after my finding (I know I should have try it before as you suggested, I just didn't wanted to even think of such solution) there will be more data to be able to diagnose it. I was reading that tomcat is quite special when it comes to resolving classpaths (http://www.mulesoft.com/tomcat-classpath), but at the moment have no idea if this could be the problem here.

Denny

unread,
Feb 21, 2013, 7:57:15 PM2/21/13
to ra...@googlegroups.com
On 2/21/13 4:25 PM, Jacek wrote:
> Copied symbolic links, physical directories and files to all possible
> locations of Railo - still no luck.
>

Hrm. FWIW, I know PropertyResourceBundle works, though you shouldn't
have to resort to it if you don't want to.

No, most likely you just need to get ahold of the right classloader, and
pass that in to the constructor.

It might be easiest to start with this:

var cl = getPageContext().getConfig().getClassloader();
...=Variables.instance.rB.getBundle(arguments.rbFile,thisLocale,cl);

And then add .getParent() until you get to the system classloader:

.getBundle(arguments.rbFile,thisLocale,cl.getParent().getParent()...)

There's nowhere to go after the system classloader.

You could probably manually add the property file resource to the
classloader before passing the classloader in, but you shouldn't have to
resort to that.

:Denny

--
Railo Technologies: getrailo.com Professional Open Source
Skype: valliantster (505)510.1336 de...@getrailo.com
GnuPG-FP: DDEB 16E1 EF43 DCFD 0AEE 5CD0 964B B7B0 1C22 CB62
Reply all
Reply to author
Forward
0 new messages