You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "G.L. Grobe" <ga...@grobe.org> on 2001/04/18 05:27:13 UTC

struts not reading properties file

I've posted this once, but nothing led me to any ideas. I was using Orion 1.4.5 and now I've upgraded to 1.4.7 in hopes of seeing something different to no avail. Here's the error and below that is the section of web.xml that points to the properties file and below that is the section of index.jsp  with the message key itself. 

Any help much appreicated, or even ideas of debugging.

 500 Internal Server Error
javax.servlet.jsp.JspException: Missing message for key main.title at
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java,
Compiled Code) at /index.jsp._jspService(/index.jsp.java, Compiled Code) at 
...
------ ~WEB-INF/web.xml ------------------------

   <servlet>
      <servlet-name>action</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <init-param>
         <param-name>application</param-name>
         <param-value>cais</param-value>
      </init-param>


------ ~/index.jsp ------------------------

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html>
<head>
<title>
   <bean:message key="main.title" />
</title>

------ ~WEB-INF/classes/cais.properties ------------------------

# C.A.I.S. Resource Bundle
main.title=CAIS
main.master=Master View
main.detail=Detailed View


struts MessageTag.java not reading properties file

Posted by "G.L. Grobe" <ga...@grobe.org>.
I've dug into the struts code and am posting this problem again w/ a little more info. I'm using Orion 1.4.7. 

500 Internal Server 
Error javax.servlet.jsp.JspException: Missing message for key main.title at 
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java,
Compiled Code) at /index.jsp._jspService(/index.jsp.java, Compiled Code) at ...

According to the above error and this snippit of code taken from the 4-20 tar.gz source, the properties file that my web-app is looking for is being found and all seems to be setup/configured correctly, else the error would be about messageTag.resources (not finding the property file). I've also included my properties (cais.properties) file below with this key included in it.

The only thing else I think that can be wrong is the value of the args array just before the Exception is thrown and I was wondering if anyone could tell me what those might be.

The line with 'String message = resources.getMessage(locale, key, args);' must be returning null and so this is giving me the above error, but I'm not sure what's being stuffed into it or where it comes from.

Any help much appreciated.

----- MessageTag.java ------------------------------------------------

  public int doStartTag() throws JspException {

   // Acquire the resources object containing our messages
   MessageResources resources = (MessageResources)
       pageContext.getAttribute(bundle, PageContext.APPLICATION_SCOPE);
   if (resources == null)
       throw new JspException
      (messages.getMessage("messageTag.resources", bundle));

   // Calculate the Locale we will be using
   Locale locale = null;
   try {
       locale = (Locale)
      pageContext.getAttribute(localeKey, PageContext.SESSION_SCOPE);
   } catch (IllegalStateException e) { // Invalidated session
       locale = null;
   }
   if (locale == null)
       locale = defaultLocale;

   // Construct the optional arguments array we will be using
   Object args[] = new Object[5];
   args[0] = arg0;
   args[1] = arg1;
   args[2] = arg2;
   args[3] = arg3;
   args[4] = arg4;

   // Retrieve the message string we are looking for
   String message = resources.getMessage(locale, key, args);
   if (message == null)
       throw new JspException
      (messages.getMessage("messageTag.message", key));


------ ~WEB-INF/web.xml ------------------------   
<servlet>
      <servlet-name>action</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <init-param>
         <param-name>application</param-name>
         <param-value>cais</param-value>
      </init-param>
   ...

------ ~/index.jsp ------------------------
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html>
<head>
<title>
   <bean:message key="main.title" />
</title>

------ ~WEB-INF/classes/cais.properties ------------------------
# C.A.I.S. Resource Bundle
main.title=CAIS
main.master=Master View
main.detail=Detailed View


Re: struts not reading properties file

Posted by Rajan Gupta <rg...@yahoo.com>.
Have u provide the correct location of ApplicationResources in web.xml?
--- "G.L. Grobe" <ga...@grobe.org> wrote:
> Agreed, but not the case.
> 
> ----- Original Message -----
> From: "Dan Miser" <dm...@wi.rr.com>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, April 17, 2001 11:13 PM
> Subject: Re: struts not reading properties file
> 
> 
> > Most likely you have a copy of struts.jar somewhere on your CLASSPATH.
> It
> > only belongs in WEB-INF/lib.
> > --
> > Dan Miser
> > http://www.distribucon.com
> >
> > ----- Original Message -----
> > From: G.L. Grobe
> > To: struts-user@jakarta.apache.org
> > Sent: Tuesday, April 17, 2001 10:27 PM
> > Subject: struts not reading properties file
> >
> >  500 Internal Server Error
> > javax.servlet.jsp.JspException: Missing message for key main.title at
> > org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java,
> > Compiled Code) at /index.jsp._jspService(/index.jsp.java, Compiled
> Code)
> at
> >
> >
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Re: struts not reading properties file

Posted by "G.L. Grobe" <ga...@grobe.org>.
Agreed, but not the case.

----- Original Message -----
From: "Dan Miser" <dm...@wi.rr.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, April 17, 2001 11:13 PM
Subject: Re: struts not reading properties file


> Most likely you have a copy of struts.jar somewhere on your CLASSPATH. It
> only belongs in WEB-INF/lib.
> --
> Dan Miser
> http://www.distribucon.com
>
> ----- Original Message -----
> From: G.L. Grobe
> To: struts-user@jakarta.apache.org
> Sent: Tuesday, April 17, 2001 10:27 PM
> Subject: struts not reading properties file
>
>  500 Internal Server Error
> javax.servlet.jsp.JspException: Missing message for key main.title at
> org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java,
> Compiled Code) at /index.jsp._jspService(/index.jsp.java, Compiled Code)
at
>
>


Re: struts not reading properties file

Posted by Dan Miser <dm...@wi.rr.com>.
Most likely you have a copy of struts.jar somewhere on your CLASSPATH. It
only belongs in WEB-INF/lib.
--
Dan Miser
http://www.distribucon.com

----- Original Message -----
From: G.L. Grobe
To: struts-user@jakarta.apache.org
Sent: Tuesday, April 17, 2001 10:27 PM
Subject: struts not reading properties file

 500 Internal Server Error
javax.servlet.jsp.JspException: Missing message for key main.title at
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java,
Compiled Code) at /index.jsp._jspService(/index.jsp.java, Compiled Code) at



Re: struts not reading properties file

Posted by Chris Butler <pa...@orpheusdesign.com>.
well, for me with weblogic i noticed that putting
a specific location in the classpath helps...
and putting the file there.  in the case below
it would require putting your properties file
in /com/yourDomain java classpath.

    <servlet>
       <servlet-name>action</servlet-name>
       <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
       <init-param>
          <param-name>application</param-name>
          <param-value>com.yourDomain.cais</param-value>
       </init-param>

not sure that helps, lemme know.

c

At 10:27 PM 4/17/2001 -0500, G.L. Grobe wrote:
>I've posted this once, but nothing led me to any ideas. I was using Orion 
>1.4.5 and now I've upgraded to 1.4.7 in hopes of seeing something 
>different to no avail. Here's the error and below that is the section of 
>web.xml that points to the properties file and below that is the section 
>of index.jsp  with the message key itself.
>
>Any help much appreicated, or even ideas of debugging.
>
>  500 Internal Server Error
>javax.servlet.jsp.JspException: Missing message for key main.title at
>org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java,
>Compiled Code) at /index.jsp._jspService(/index.jsp.java, Compiled Code) at
>...
>------ ~WEB-INF/web.xml ------------------------
>
>    <servlet>
>       <servlet-name>action</servlet-name>
>       <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>       <init-param>
>          <param-name>application</param-name>
>          <param-value>cais</param-value>
>       </init-param>
>
>------ ~/index.jsp ------------------------
>
><%@ page language="java" %>
><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
>
><html:html>
><head>
><title>
>    <bean:message key="main.title" />
></title>
>------ ~WEB-INF/classes/cais.properties ------------------------
>
># C.A.I.S. Resource Bundle
>main.title=CAIS
>main.master=Master View
>main.detail=Detailed View