• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error in properties file

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts-config.xml:

<message-resources parameter="MessageResources" />
<message-resources key="test" parameter="TestMessageResources" null="false" />

TestMessageResources.properties is in /WEB-INF/classes.

TestMessageResources.properties:

form.firstName=First Name.
form.lastName=Last Name.
form.emailID=Email ID.
form.password=Password.

JSP files:
<bean:message bundle="test" key="form.firstName" />: <html:text property="firstName"/><br>
<bean:message bundle="test" key="form.lastName" />: <html:text property="lastName"/><br>
<bean:message bundle="test" key="form.emailID" /> : <html:text property="email"/><br>
<bean:message bundle="test" key="form.password" /> : <html:text property="password"/><br>

This is what i get

???en_US.form.firstName???:
???en_US.form.lastName???:
???en_US.form.emailID??? :
???en_US.form.password??? :

When I include the keys in MessageResources, the default file,and change my jsp, it works fine. what is the problem.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I can tell you, Krisp, is that you must be making some small error somewhere. When I try this exact same scenario in a test application, it works fine for me. Are you misspelling the name of the properties file? does it really exist in WEB-INF/classes? Are you remembering to restart the server after making changes in the message bundle files or the struts-config.xml file?

The only other thing I'd suggest is to check the integrity of your Struts installation. Make sure all artifacts are from the same Struts download (including jar files, xml files, etc.), and that the DTD referenced in the struts-config.xml file matches the one found in the sample config file in the struts-blank.war file.
[ March 22, 2007: Message edited by: Merrill Higginson ]
 
krishna prasad gunasekaran
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I checked everything. It's fine. I started my server and typed in the address. the following error mesage appeared.

exception

org.apache.jasper.JasperException: java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
java.util.Properties.loadConvert(Unknown Source)
java.util.Properties.load(Unknown Source)
org.apache.struts.util.PropertyMessageResources.loadLocale(PropertyMessageResources.java:250)
org.apache.struts.util.PropertyMessageResources.getMessage(PropertyMessageResources.java:177)
org.apache.struts.util.MessageResources.getMessage(MessageResources.java:296)
org.apache.struts.taglib.TagUtils.message(TagUtils.java:953)
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:221)
org.apache.jsp.login_jsp._jspx_meth_bean_005fmessage_005f0(login_jsp.java:165)
org.apache.jsp.login_jsp._jspx_meth_html_005fform_005f0(login_jsp.java:106)
org.apache.jsp.login_jsp._jspService(login_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:390)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



when i refresh the the page, the jsp page was displayed, but without proper messages in that particular properties file.

[B]???en_US.form.firstName???: text area
???en_US.form.lastName???: text area
???en_US.form.emailID??? : text area
???en_US.form.password???: text area
signup button.[/B]

this behaviour happens over and over again. the first time, I start the server, the error message appears, and when i refresh the page the jsp page was displayed with messages in propeties file missing. why does this behaviour occur? start the server, error, refresh, jsp page displayed without message in properties file.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The messages in the stack trace indicate that your properties file has invalid characters in it. My recommendation would be to create a new file and re-type the messages into it (Don't cut and paste). Make sure whatever text editor you're using is set to output plain text and not unicode. Then delete the old file and copy the new one into the WEB-INF/classes directory.
[ March 27, 2007: Message edited by: Merrill Higginson ]
 
krishna prasad gunasekaran
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but, why is this anomalous behaviour - after every restart of the server, the first request produces an error and the subsequent refreshing produces the desired page, with key messages in properties file missing.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts uses "lazy initialization" to initialize the message bundles. The first time you try to access a message, it gives you the error message that it wasn't able to initialize the bundle. The second and subsequent times, it gives you the results of an uninitialized bundle: Messages are not found.
 
reply
    Bookmark Topic Watch Topic
  • New Topic