Problem with customizing validation messages

28 views
Skip to first unread message

Enrique Villamizar

unread,
Jan 7, 2010, 5:38:08 PM1/7/10
to javaee6-...@googlegroups.com
Hello once again to everybody:
 
I keep on learning...Before describing my issue let me let you know that I posted yesterday in Javaranch. http://www.coderanch.com/t/477551/JSF/java/JSF-with-customizing-validation-messages
 
What I'm trying to do I've already done it with no problems using Netbeans 6.7.1, JSF 1.2 and Tomcat 6.

Now I'm using Netbeans 6.8, JSF 2.0, Facelets, Java EE 6 and GlassFish v3

1. I created a property file, under the source package com.domain.util, I named it myMessages.properties
2. I delcared a new message bundle in faces-config.xml

<application>   <message-bundle> com.domain.util.myMessages</message-bundle> </application>   


When I run it:
 
An Error Occurred:  

Can't find bundle for base name com.domain.util.myMessages, locale es_CO  

java.util.MissingResourceException: Can't find bundle for base name com.cajasan.vivienda.mensajesValidaciones, locale es_CO  

   at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521)      

   at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)  .....  

Thanks in advanced for your kind help.


--
Cordialmente;

Enrique Villamizar
My mother tongue is Spanish.

Jason Porter

unread,
Jan 7, 2010, 5:50:24 PM1/7/10
to enriquev...@gmail.com, javaee6-...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups
> "javaee6-codecamp" group.
> To post to this group, send email to javaee6-...@googlegroups.com.
> To unsubscribe from this group, send email to
> javaee6-codeca...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/javaee6-codecamp?hl=en.
>
>

For whatever reason it's looking for a properties file
com.cajasan.vivienda.mensajesValidaciones
(mensajesValidaciones.properties in the com.cajasan.vivienda package).

--
Jason Porter
Real Programmers think better when playing Adventure or Rogue.

PGP key id: 926CCFF5
PGP fingerprint: 64C2 C078 13A9 5B23 7738 F7E5 1046 C39B 926C CFF5
PGP key available at: keyserver.net, pgp.mit.edu

Enrique Villamizar

unread,
Jan 7, 2010, 6:08:10 PM1/7/10
to Jason Porter, javaee6-...@googlegroups.com
Hi Jason:
 
Sorry...it was my fault ... I made a copy-paste mistake mixing two messages of the same problem but two different projects.
 
The correct one is:
 
    •  An Error Occurred:  
    • Can't find bundle for base name com.domain.util.myMessages, locale es_CO  
    • java.util.MissingResourceException: Can't find bundle for base name com.domain.util.myMessages, locale es_CO  
    •     at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521)  
    •     at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)  
       
      I have the same project in Netbeans 6.7.1, JSF 1.2 and Tomcat 6.0 and it works.  I also added to faces-config
       
      <locale-config>
               <default-locale>es_CO</default-locale>
               <supported-locale>es_CO</supported-locale>
           </locale-config>
       
      But the same problem. This example is based on http://netbeans.org/kb/67/web/jastrologer-validate.html#changedefault
       
      Thank you.
       
      --
      Cordialmente;

      Enrique Villamizar
      English is not my mother tongue.

      Jason Porter

      unread,
      Jan 7, 2010, 6:38:02 PM1/7/10
      to Enrique Villamizar, javaee6-...@googlegroups.com
      On Thu, Jan 7, 2010 at 16:08, Enrique Villamizar
      <enriquev...@gmail.com> wrote:
      > Hi Jason:
      >
      > Sorry...it was my fault ... I made a copy-paste mistake mixing two messages
      > of the same problem but two different projects.
      >
      > The correct one is:
      >
      >  An Error Occurred:
      > Can't find bundle for base name com.domain.util.myMessages, locale es_CO
      > java.util.MissingResourceException: Can't find bundle for base name com.domain.util.myMessages, locale es_CO
      >     at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521)
      >     at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)
      >
      > I have the same project in Netbeans 6.7.1, JSF 1.2 and Tomcat 6.0 and it
      > works.  I also added to faces-config
      >
      > <locale-config>
      >          <default-locale>es_CO</default-locale>
      >          <supported-locale>es_CO</supported-locale>
      >      </locale-config>
      >
      > But the same problem. This example is based on
      > http://netbeans.org/kb/67/web/jastrologer-validate.html#changedefault
      >
      > Thank you.
      >
      > --
      > Cordialmente;
      >
      > Enrique Villamizar
      > English is not my mother tongue.
      > 2010/1/7 Jason Porter <lightg...@gmail.com>

      Okay, paste your faces-config.xml. Also make sure the properties file
      is actually in the correct space in your archive.

      András Iványi

      unread,
      Jan 8, 2010, 5:26:48 AM1/8/10
      to javaee6-...@googlegroups.com

      Üdv:
      Andy


      ---------- Forwarded message ----------
      From: András Iványi <andras...@gmail.com>
      Date: Fri, Jan 8, 2010 at 11:26 AM
      Subject: Re: [javaee6-codecamp] Problem with customizing validation messages
      To: enriquev...@gmail.com


      I'm not sure, but what if you copy your myMessages.properties file to myMessages_es_CO.properties or mymessages_es.properties?

      Andy

      Enrique Villamizar

      unread,
      Jan 8, 2010, 7:08:34 AM1/8/10
      to javaee6-...@googlegroups.com
      Just forwarding to the group.
      Hi Jason:
       
      1. My faces-config.xml:
       
      <faces-config version="2.0"
                    xmlns="
      http://java.sun.com/xml/ns/javaee"
                    xmlns:xsi="
      http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="
      http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
       
       <application>
          <message-bundle>com.cajasan.vivienda.mensajesValidaciones</message-bundle>

          <locale-config>
               <default-locale>es_CO</default-locale>
               <supported-locale>es_CO</supported-locale>
           </locale-config>
           <resource-bundle>
               <base-name>com.cajasan.vivienda.web.mensajesGlobales</base-name>
               <var>msgGlobales</var>
           </resource-bundle>
       </application>
      ...
      </faces-config>
       
      2. propertie file location:
       
       
      ?ui=2&view=att&th=1260b2f3f897b541&attid=0.1&disp=attd&realattid=ii_1260b2f3f897b541&zw
       
      Please notice than mensajesGlobales (it means "general messages") is working fine.
       
      3) Content of mensajesValidaciones_es_CO.properties
       
      javax.faces.component.UIInput.REQUIRED=Campo obligatorio.
      javax.faces.converter.DateTimeConverter.DATE=Digite una fecha.
      javax.faces.converter.DateTimeConverter.DATE_detail=Por favor ingrese una fecha válida. Ejemplo: {1}
      javax.faces.validator.LongRangeValidator.NOT_IN_RANGE = Valor no se encuentra entre {0} y {1}.
      javax.faces.validator.LongRangeValidator.MINIMUM = valor menor que el mínimo permitido de {0}.
      javax.faces.validator.LongRangeValidator.MAXIMUM = valor mayor que el máximo permitido de {1}.
       
      Based on German Escobar idea http://www.coderanch.com/t/477551/JSF/java/JSF-with-customizing-validation-messages   I changed the name of the propertie file.
       
      4) Error when I run it:
      java.util.MissingResourceException: Can't find bundle for base name com.cajasan.vivienda.mensajesValidaciones, locale es_CO at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.
      java:1260)
      	at java.util.ResourceBundle.getBundle(ResourceBundle.java:962)
      	at com.sun.faces.util.MessageFactory.getMessage(MessageFactory.java:159)
      	at com.sun.faces.util.MessageFactory.getMessage(MessageFactory.java:136)
      	at com.sun.faces.util.MessageUtils.getExceptionMessageString(MessageUtils.java:373)
      	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getForComponent(HtmlBasicRenderer.java:436)
      	at com.sun.faces.renderkit.html_basic.LabelRenderer.encodeBegin(LabelRenderer.java:89)
      	at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:823)
      	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:285)
      	at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
      	at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
      	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
      	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:287)
      	at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:106)
      	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
      	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:287)
      	at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:106)
      	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
      	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
      	at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
      	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
      	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
      	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
      	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
      	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
      	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
      	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
      	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
      	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
      	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
      	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
      	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
      	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
      	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
      	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
      	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
      	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
      	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
      	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
      	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
      	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
      	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
      	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
      	at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
      	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
      	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
      	at java.lang.Thread.run(Thread.java:619)
      
       
       
      Thank you for your help.


      --
      Cordialmente;

      Enrique Villamizar
      My mother tongue is Spanish.
       
      2010/1/7 Jason Porter <lightguard.jp@gmail.com>
      localeError.PNG

      Jason Porter

      unread,
      Jan 8, 2010, 11:00:03 AM1/8/10
      to enriquev...@gmail.com, javaee6-...@googlegroups.com
      Hey looking at this again, the message bundle that's not working is in the wrong package. In your faces-config you didn't say it's in the web package, but in your code screenshot it is. 

      Sent from my iPhone

      On Jan 8, 2010, at 5:08, Enrique Villamizar <enriquev...@gmail.com> wrote:

      Just forwarding to the group.
      Hi Jason:
       
      1. My faces-config.xml:
       
      <faces-config version="2.0"
                    xmlns="
      http://java.sun.com/xml/ns/javaee"
                    xmlns:xsi="
      http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="
      http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
       
       <application>
          <message-bundle>com.cajasan.vivienda.mensajesValidaciones</message-bundle>

          <locale-config>
               <default-locale>es_CO</default-locale>
               <supported-locale>es_CO</supported-locale>
           </locale-config>
           <resource-bundle>
               <base-name>com.cajasan.vivienda.web.mensajesGlobales</base-name>
               <var>msgGlobales</var>
           </resource-bundle>
       </application>
      ...
      </faces-config>
       
      2. propertie file location:
       
       
      <localeError.PNG>

      Enrique Villamizar

      unread,
      Jan 8, 2010, 11:15:30 AM1/8/10
      to Jason Porter, javaee6-...@googlegroups.com
      YES...YES!
       
      My God ... what a silly mistake!
       
      I promise to visit the optometrist or at least change my glasses!
       
      Thank you very much for your time, patient and, help.

      --
      Cordialmente;

      Enrique Villamizar
      My mother tongue is Spanish.
       
      Reply all
      Reply to author
      Forward
      0 new messages