1 Reply Latest reply on Jan 20, 2010 11:55 AM by Rémi Magnin

    Problem with SeamResourceBundle when changing Locale

    Rémi Magnin Newbie

      Hello,


      I have a problem using the SeamResourceBundle when I change the language of my application from French (which is the default locale) to English : the right messages.properties does not seem to be loaded correctly and the bundle can't find my key. But messages_en.properties exists and contains the key I try to reach.
      The key exists in all messages.properties for all the supported locale.


      The code in my java class is the following :


      @Stateful
      @Name("estimationAction")
      @Scope(ScopeType.CONVERSATION)
      public class EstimationAction implements IEstimationAction {
      
            [...]
      
            public Map<String, Float> getRisques() {
                Map<String, Float> risques = new LinkedHashMap<String, Float>();
                Float [] resultats = EstimationDesRisques.getRisqueByEstimation(
                          this.dureeExposition, 
                          this.probabiliteOccurence, 
                          this.probabiliteEvitement, 
                          this.graviteDommage);
                
                      ResourceBundle resourceBundle = SeamResourceBundle.getBundle();
                
                      String important = 
                     resourceBundle.getString(CleMessage.ESTIMATION_GRAPH_IMPORTANT);
                String moyen = 
                     resourceBundle.getString(CleMessage.ESTIMATION_GRAPH_MOYEN);
                String faible = 
                     resourceBundle.getString(CleMessage.ESTIMATION_GRAPH_FAIBLE);
                risques.put(important, resultats[0]);
                risques.put(moyen, resultats[1]);
                risques.put(faible, resultats[2]);
                return risques;
           }
      
              [...]
      
      }



      It works fine as long as I don't change the locale of the application.
      But when I change it, I got this exception :


      javax.el.ELException: /pages/visiteur/Estimation1.xhtml @251,37 value="#{estimationAction.risques}": Error reading 'risques' on type org.javassist.tmp.java.lang.Object_$$_javassist_seam_14
      
      Caused by: java.util.MissingResourceException: Can't find resource for bundle org.jboss.seam.core.SeamResourceBundle, key estimation_graph_important
           at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
           at java.util.ResourceBundle.getString(ResourceBundle.java:285)
           at fr.inrs.loginorme.web.controller.analyse.EstimationAction.getRisques(EstimationAction.java:387)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
           at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
           at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInterceptor.java:138)
           at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:65)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:29)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:30)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
           at sun.reflect.GeneratedMethodAccessor4930.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:83)
           at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:70)
           at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:59)
           at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
           at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
           at sun.reflect.GeneratedMethodAccessor4929.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
           at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_23654984.invoke(InvocationContextInterceptor_z_fillMethod_23654984.java)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
           at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_23654984.invoke(InvocationContextInterceptor_z_setup_23654984.java)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:60)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
           ... 129 more
      



      I don't what I'm doing wrong when calling the SeamResourceBundle.
      Hope you can help me out.


      Thanks.


      Rémi