velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anthony E. Carlos" <anth...@digitalphenom.com>
Subject Re: MessageResourcesTool: Message resources are not available.
Date Fri, 22 Oct 2004 05:49:25 GMT
Shinobu,

Here's my web.xml:
   <!-- Standard Action Servlet Configuration (with debugging) -->
   <servlet>
      <servlet-name>action</servlet-name>
      
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <init-param>
       <param-name>application</param-name>
       <param-value>resources.application</param-value>
     </init-param>

My resource file is in 
/WEB-INF/classes/resources/application.properties. What's weird is that 
I can access properties from within my Struts Action and set them into 
the request context and display them on the page with Velocity. Thus, I 
know that my resources file is correctly being accessed by Struts. As I 
said earlier, my whole setup was working until I changed my struts.jar 
file (from version 1.1 to 1.2.4).

Since you asked, here's the other part of web.xml:
<!-- Define Velocity template compiler -->
<servlet>
   <servlet-name>velocity</servlet-name>
   <servlet-class>
     org.apache.velocity.tools.view.servlet.VelocityViewServlet
   </servlet-class>
   <init-param>
     <param-name>org.apache.velocity.toolbox</param-name>
     <param-value>/WEB-INF/conf/toolbox.xml</param-value>
  </init-param>
   <init-param>
     <param-name>org.apache.velocity.properties</param-name>
     <param-value>/WEB-INF/conf/velocity.properties</param-value>
  </init-param>
  <load-on-startup>10</load-on-startup>
</servlet>

And part of my toolbox.xml:
<toolbox>
   <tool>
      <key>messages</key>
      <scope>request</scope>
      <class>org.apache.velocity.tools.struts.ActionMessagesTool</class>
   </tool>
...

I found the part of VelocityTools that created the message. It's from 
MessageResourcesTool.java...

     /**
      * Retrieves the specified {@link MessageResources} bundle, or the
      * application's default MessageResources if no bundle is specified.
      * @since VelocityTools 1.1
      */
     protected MessageResources getResources(String bundle)
     {
         if (bundle == null) // <---MUST BE NULL?
         {
             if (resources == null) // <---MUST BE NULL?
             {
                 Velocity.error("MessageResourcesTool: Message resources 
are not available.");
             }
             return resources;
         }

         MessageResources res =
             StrutsUtils.getMessageResources(request, application, 
bundle);
         if (res == null)
         {
             Velocity.error("MessageResourcesTool: MessageResources 
bundle '"
                            + bundle + "' is not available.");
         }
         return res;
     }

It looks like both the bundle and the resources are null. How can this 
be? Is it a bug or can I do something to ensure that both are not null?

Thanks for your help!

-Anthony





Hi Anthony,

 > I'm still having trouble using the ActionMessagesTool. However, I've
 > found some more info. In one of the log files, Velocity posts the
 > following error:
 >
 > MessageResourcesTool: Message resources are not available.
Worked on my place.  Could you provide a bit more information?
- Where is your resource file?
- How are you configuring the resource file in your struts-config.xml?
- How are you configuring your ActionMessagesTool in toolbox.xml?

Best regards,
-- Shinobu Kawai


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message