You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Peter Mahoney <pm...@digitalbrain.com> on 2005/06/14 17:32:21 UTC

Resource bundle not found

I am trying to move from the RI to MyFaces, but have been getting the 
error "Resource bundle 'x' not found". Tomcat is running using the 
Eclipse plugin. There is a 'jsflib' project added to the tomcat 
classpath which includes JSF components and helper classes. The web 
application project itself includes the resource bundle and has the 
'jsflib' project in its classpath. This arrangement allows the running 
of applications during development without any manual build step.

I have found the cause of the problem to be in the class LoadBundleTag. 
The class loader of the current thread is used to locate the resource 
bundle, but in the above setup this class loader is returned as null. 
The RI includes a fallback clause which uses the current classes' class 
loader to locate the resource bundle in this case. I changed the 
LoadBundleTag code to:

            ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
           
            if (classLoader == null) {
                classLoader = this.getClass().getClassLoader();
            }
            bundle = ResourceBundle.getBundle(basename, locale, 
classLoader);

And this appears to solve the problem. Is this the correct fix (to be 
raised in jira) or is the development environment incorrect?

Thanks

Peter


Re: Resource bundle not found

Posted by "Ricardo R. Ramírez Valenzuela" <rr...@itesm.mx>.
This is indeed very useful information, I had the same problem and the 
only way I was able to solve it was to put myfaces.jar and 
myfaces-jsf.jar under the WEB-INF/lib directory

However, i am know seeing another problem that might be related to this 
one. Myfaces is unable to find my managed beans, I think that's because 
the myfaces classes are in the shared lib directory and the managed 
beans are under WEB-INF/classes.



Peter Mahoney wrote:

> I am trying to move from the RI to MyFaces, but have been getting the 
> error "Resource bundle 'x' not found". Tomcat is running using the 
> Eclipse plugin. There is a 'jsflib' project added to the tomcat 
> classpath which includes JSF components and helper classes. The web 
> application project itself includes the resource bundle and has the 
> 'jsflib' project in its classpath. This arrangement allows the running 
> of applications during development without any manual build step.
>
> I have found the cause of the problem to be in the class 
> LoadBundleTag. The class loader of the current thread is used to 
> locate the resource bundle, but in the above setup this class loader 
> is returned as null. The RI includes a fallback clause which uses the 
> current classes' class loader to locate the resource bundle in this 
> case. I changed the LoadBundleTag code to:
>
>            ClassLoader classLoader = 
> Thread.currentThread().getContextClassLoader();
>                      if (classLoader == null) {
>                classLoader = this.getClass().getClassLoader();
>            }
>            bundle = ResourceBundle.getBundle(basename, locale, 
> classLoader);
>
> And this appears to solve the problem. Is this the correct fix (to be 
> raised in jira) or is the development environment incorrect?
>
> Thanks
>
> Peter
>