You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Albert Moliner <am...@evintia.com> on 2003/02/14 13:04:45 UTC
Message resources, as usual
Hello.
I know this question has been repeating again and again and again, but I
still have not been able to understand what's the difference between what I
do and what I should do. Sorry.
I've been using struts for nearly two years now, but laziness has made me
stuck to old versions, until I can't resist it anymore. One of the features
I'd like to use is the possibility to retrieve texts from different resource
bundles. To achieve it, what I do is the following (with the 1.1 jar, of
course):
In struts-config.xml, I have the following deffinitions for my testing:
<message-resources parameter="Resources1" key="res1"/>
<message-resources parameter="Resources2" key="res2"/>
Inside WEB-INF/classes I have two files, Resources1.properties and
Resources2.properties, which look like this:
string1 = res1 str1
string2 = res1 str2
(Resources2 just has "res2" instead of "res1" after the equal symbol).
Then, I call a jsp with contents like the following:
...
<bean:message key="string1" bundle="res1"/>
...
But the result is not the html with the "res1 str1" bit, but the typical
exception page with the following root cause trace:
------------------
javax.servlet.ServletException: Missing message for key string1
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:530)
at org.apache.jsp.messagestest_jsp._jspService(messagestest_jsp.java:116)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
04)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:260)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:386)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:530)
at java.lang.Thread.run(Thread.java:536)
--------------------
Where am I wrong?? Thank you very much,
Albert.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Message resources, as usual
Posted by Albert Moliner <am...@evintia.com>.
Forgive me for my insisting on the subject.
Just to be sure nothing is escaping from my attention, when I try and modify
the jsp bean:message tag, telling it to use a non-defined RB ("aares1"
instead of "res1"), the exception is
----------
javax.servlet.jsp.JspException: Cannot find message resources under key
aares1
at
org.apache.struts.util.RequestUtils.message(RequestUtils.java:939)
at
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:295)
at
org.apache.jsp.messagestest_jsp._jspx_meth_bean_message_0(messagestest_jsp.j
ava:131)
at
org.apache.jsp.messagestest_jsp._jspService(messagestest_jsp.java:83)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
04)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
...ETCETERA
----------
This makes me think that originally the resource bundle was really found, as
else the exception would be like the one displayed above, and not the
"Missing message for key string1" that I got.
I'll take a look at what the bean:message tag is doing, to see if I get a
clue.
Albert.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Message resources, as usual
Posted by Albert Moliner <am...@evintia.com>.
> > Just a quick suggestion, this shouldn't make a difference, but change
> this:
> > string1 = res1 str1
> > string2 = res1 str2
> >
> >
> > to this:
> > string1= res1 str1
> > string2= res1 str2
As far as I know they are the same, as both halves of the equality are
trimmed when parsed, and formerly (when using one single RB) they worked.
Anyway, I've tried, and it's still the same.
Thank you anyway.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Message resources, as usual
Posted by Simon Kelly <ke...@ipe.fzk.de>.
Hate to be the one to point this out, but they are both the same ;-)
----- Original Message -----
From: "James Mitchell" <jm...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, February 14, 2003 2:54 PM
Subject: Re: Message resources, as usual
> Just a quick suggestion, this shouldn't make a difference, but change
this:
> string1 = res1 str1
> string2 = res1 str2
>
>
> to this:
> string1= res1 str1
> string2= res1 str2
>
>
> Other than that I can't imagine what the problem is. This obviously works
> in the example app.
>
> Good Luck.
>
> --
> James Mitchell
>
>
>
>
>
> ----- Original Message -----
> From: "Albert Moliner" <am...@evintia.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Friday, February 14, 2003 7:09 AM
> Subject: Re: Message resources, as usual
>
>
> >
> > Mmm, sorry, I'd better show you a better stack trace, caught "manually"
in
> > the jsp by me:
> >
> > ---------------
> > javax.servlet.jsp.JspException: Missing message for key string1
> > at
> > org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:298)
> > at
> >
>
org.apache.jsp.messagestest_jsp._jspx_meth_bean_message_0(messagestest_jsp.j
> > ava:131)
> > at
> > org.apache.jsp.messagestest_jsp._jspService(messagestest_jsp.java:83)
> > at
> > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at
> >
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
> > 04)
> > at
> > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > ... AND MORE
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Message resources, as usual
Posted by James Mitchell <jm...@apache.org>.
Just a quick suggestion, this shouldn't make a difference, but change this:
string1 = res1 str1
string2 = res1 str2
to this:
string1= res1 str1
string2= res1 str2
Other than that I can't imagine what the problem is. This obviously works
in the example app.
Good Luck.
--
James Mitchell
----- Original Message -----
From: "Albert Moliner" <am...@evintia.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, February 14, 2003 7:09 AM
Subject: Re: Message resources, as usual
>
> Mmm, sorry, I'd better show you a better stack trace, caught "manually" in
> the jsp by me:
>
> ---------------
> javax.servlet.jsp.JspException: Missing message for key string1
> at
> org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:298)
> at
>
org.apache.jsp.messagestest_jsp._jspx_meth_bean_message_0(messagestest_jsp.j
> ava:131)
> at
> org.apache.jsp.messagestest_jsp._jspService(messagestest_jsp.java:83)
> at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
> 04)
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> ... AND MORE
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Message resources, as usual
Posted by Albert Moliner <am...@evintia.com>.
Mmm, sorry, I'd better show you a better stack trace, caught "manually" in
the jsp by me:
---------------
javax.servlet.jsp.JspException: Missing message for key string1
at
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:298)
at
org.apache.jsp.messagestest_jsp._jspx_meth_bean_message_0(messagestest_jsp.j
ava:131)
at
org.apache.jsp.messagestest_jsp._jspService(messagestest_jsp.java:83)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
04)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
... AND MORE
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org