struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hohlen, John" <JHoh...@erac.com>
Subject RE: Question: Configuring Multiple <message-resources> Elements W ith Sub-Applications
Date Tue, 10 Sep 2002 17:56:12 GMT
Whoops!  In my examples below, the <action> tags should actually be
<action-mappings>.  That was a cut-and-paste error on my part and not
relevant to this problem.  I fixed the examples in this reply.

-----Original Message-----
From: Hohlen, John 
Sent: Tuesday, September 10, 2002 11:43 AM
To: Struts-Help (E-mail)
Cc: 'chuckcavaness@attbi.com'
Subject: Question: Configuring Multiple <message-resources> Elements
With Sub-Applications


If I'm using multiple message resource files with sub-applications, do I
need declare all the message resource files in the default struts config
file or do I declare each message resource file in the corresponding
sub-app's struts config file? I searched the mailing lists, Struts
documentation, and the online chapter's in Chuck Cavaness' upcoming Struts
book (O'Reilly).  I have not found a clear example on how to do this.


Example #1 - Declaring All Message Resources In struts-config.xml:
=================================================================

              --- struts-config.xml-----
<struts-config>
  <message-resources parameter="com.abc.training.Messages" 
                          null="false"/> 
                                                            
  <message-resources key="SUB_APP_A_MESSAGES_KEY" 
               parameter="com.abc.training.SubAppAMessages" 
                    null="false"/>              

</struts-config>

          --- struts-config-sub-app-a.xml-----
<struts-config>
   <form-beans>    
     ...
   </form-beans>
   <action-mappings>
     ...
   </action-mappings>
</struts-config>



Example #2 - Declaring Each Message Resource In Each Sub App's
struts-config-xml:
============================================================================
====

              --- struts-config.xml-----
<struts-config>
  <message-resources parameter="com.abc.training.Messages" 
                          null="false"/>

</struts-config>


          --- struts-config-sub-app-a.xml-----
<struts-config>
  <form-beans>    
    ...
  </form-beans>
  <action-mappings>
    ...
  </action-mappings>

  <message-resources key="SUB_APP_A_MESSAGES_KEY" 
               parameter="com.abc.training.SubAppAMessages" 
                    null="false"/>              

</struts-config>

I can't get either approach to work.  If I use approach #1, error keys are
not properly located for errors placed in the errors container by
sub-application A.  Hence, error mesages appear as "???en_US.<key>???.  But
this approach does work for JSP text retrieved from sub-app A's message
resource file (as long as I specify the "bundle" attribute).  

If I use approach #2, I get the following exception (WebLogic 6.1 with SP2
or SP3):
   
javax.servlet.ServletException: Cannot find message resources under key
SUB_APP_A_MESSAGES_KEY
	at
weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImp
l.java:256)
	at
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:10
14)
	at
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProces
sor.java:417)
	at
org.apache.struts.action.RequestProcessor.processActionForward(RequestProces
sor.java:390)
	at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:271)
	at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
	at
com.erac.fleetsystems.strutsx.FleetSystemsServlet.process(FleetSystemsServle
t.java:178)
	at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:265)
	at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:200)
	at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:2495)
	at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:2204)
	at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
	at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

I believe approach #2 makes the most sense, but I keep getting the above
servlet exception.  FYI - I have the folllowing in my web.xml file for
either approach:
  
<init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
  </init-param>
  <init-param>
    <param-name>config/subAppA</param-name>
    <param-value>/WEB-INF/struts-config-sub-app-a.xml</param-value>
  </init-param>

Thanks in advance for your help.

JOHN HOHLEN
 



--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message