DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7491>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7491

MessageResources key attribute defaults to null

           Summary: MessageResources key attribute defaults to null
           Product: Struts
           Version: 1.1 Beta 1
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Controller
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I was building a simple app to demonstrate the new multi-controller 
functionality.  I setup a simple webapp like this

<servlet>
 <servlet-name>BaseStrutsApplication</servlet-name>
 <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
     <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config-baseApp.xml</param-value>
     </init-param>
     <load-on-startup>2</load-on-startup>
</servlet>

and in the struts-config-baseApp.xml
<struts-config>
  <snip>....</snip>
  <message-resources parameter="baseProperties" />
</struts-config>


THEN, in the actionservlet I was printing out
System.out.println("'" + request.getAttribute(Action.MESSAGES_KEY) + "'");

And it was comping out NULL, and the jsp it was forwarding to was failing to 
because it couldn't find the MessageResources to lookup from.

The problem lies in the the fact that MessageResourcesConfig, they key member 
field defaults to null.  Then when the ActionServlet initialized the 
MessageResources for all of the applications using this line:

getServletContext().setAttribute(mrcs[i].getKey() + config.getPrefix(), 
resources);

it wasn't entering the Resources into the context under the correct key, and 
couldn't be looked up correctly by RequestUtils.selectApplication() using this 
line
        MessageResources resources = (MessageResources)
            context.getAttribute(Action.MESSAGES_KEY + prefix);


SOOOO the fix is to change the following line in MessageResourcesConfig:117
    protected String key = null;
to
    protected String key = org.apache.struts.action.Action.MESSAGES_KEY;


After that, all my apps/subapps retrieved all properties correctly...
If anyone needs help reproducing/etc, please feel free to write me!

Marty

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to