Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Cannot find message resources under key org.apache.struts.action.MESSAGE

Reply
Thread Tools

Cannot find message resources under key org.apache.struts.action.MESSAGE

 
 
Hari Om
Guest
Posts: n/a
 
      09-30-2003
I am using IntelliJ 3 for my JSP/Servlets and Struts application. I
have my application directory structure as follows:

C:\strutsShop --> home directory for my application
C:\strutsShop\src\books\*.class
C:\strutsShop\WEB-INF\lib\struts.jar
C:\strutsShop\WEB-INF\struts*.tld
C:\strutsShop\WEB-INF\web.xml
C:\strutsShop\*.jsp
C:\strutsShop\WEB-INF\properties\*.properties

In my JSP Page I display a Hello message. If it is US..it should
display HI and if it is French it displays BONJOIR
Basically I ma using MESSAGE.

In my ApplicationResources_en.properties I have:
index.html=Hi

and in In my ApplicationResources_fr.properties I have:
index.html=BONJOIR

My STRUTS.XML file has following:
<message-resources parameter="/WEB-INF/properties/ApplicationResources"
/>

and then I store the files in
C:\strutsShop\WEB-INF\properties\Application_en.properties

Also the above location is present in my CLASSPATH.

But when I execute the page on URL, I get
javax.servlet.ServletException: Cannot find message resources under
key org.apache.struts.action.MESSAGE

can any one help me out on this....?

THANKS
 
Reply With Quote
 
 
 
 
Wendy S
Guest
Posts: n/a
 
      09-30-2003
"Hari Om" <(E-Mail Removed)> wrote
> My STRUTS.XML file has following:
> <message-resources parameter="/WEB-INF/properties/ApplicationResources"
> />
>
> and then I store the files in
> C:\strutsShop\WEB-INF\properties\Application_en.properties
>
> Also the above location is present in my CLASSPATH.


How did you get it in your CLASSPATH? I don't know about IntelliJ, but
Tomcat picks up the CLASSPATH as it sees fit from the 'classes' and 'lib'
directories. Do you have a log file or something that assures you that this
directory really is in your CLASSPATH?

AFAIK, message-resources should be specified with dots, not slashes. And
the names have to match. Given your <message-resources> tag above, the file
should life in WEB-INF/classes and should be named
ApplicationResources.properties.

You have it elsewhere and it only has 'Application' in the name, not
'ApplicationResources'. You're on your own with the i18n underscore
extensions, but I don't think that's the problem.

If as you say the 'properties' directory is in your classpath, then you
don't have to specify the path to it.
This might work: <message-resources parameter="Application" />

An example of the dot notation would be:
<message-resources parameter="org.myco.properties.ApplicationResource s" />
and then the file would live in:
/WEB-INF/classes/org/myco/properties/ApplicationResources.properties

HTH,

--
Wendy in Chandler, AZ


 
Reply With Quote
 
 
 
 
Hari Om
Guest
Posts: n/a
 
      10-01-2003
Thanks Wendy.

Here is what I did.

My struts.xml file has:
--------------------------------------------------------------------------------<message-resources
parameter="ApplicationResources.properties" />
--------------------------------------------------------------------------------

My web.xml file has:
--------------------------------------------------------------------------------<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts.xml</param-value>
</init-param>
</servlet>
--------------------------------------------------------------------------------

I have 2 files:
ApplicationResources_en.properties and
ApplicationResources_fr.properties

These files are stored in WEB-INF/classes directory and is stored in
CLASSPATH.

When I run my browser, I get following wonder why:
--------------------------------------------------------------------------------javax.servlet.ServletException:
Cannot find message resources under key
org.apache.struts.action.MESSAGE
at org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:471)

etc.....
--------------------------------------------------------------------------------
Any hints etc on this....?

THANKS!



"Wendy S" <(E-Mail Removed)> wrote in message news:<bld3du$ght$(E-Mail Removed)>...
> "Hari Om" <(E-Mail Removed)> wrote
> > My STRUTS.XML file has following:
> > <message-resources parameter="/WEB-INF/properties/ApplicationResources"
> > />
> >
> > and then I store the files in
> > C:\strutsShop\WEB-INF\properties\Application_en.properties
> >
> > Also the above location is present in my CLASSPATH.

>
> How did you get it in your CLASSPATH? I don't know about IntelliJ, but
> Tomcat picks up the CLASSPATH as it sees fit from the 'classes' and 'lib'
> directories. Do you have a log file or something that assures you that this
> directory really is in your CLASSPATH?
>
> AFAIK, message-resources should be specified with dots, not slashes. And
> the names have to match. Given your <message-resources> tag above, the file
> should life in WEB-INF/classes and should be named
> ApplicationResources.properties.
>
> You have it elsewhere and it only has 'Application' in the name, not
> 'ApplicationResources'. You're on your own with the i18n underscore
> extensions, but I don't think that's the problem.
>
> If as you say the 'properties' directory is in your classpath, then you
> don't have to specify the path to it.
> This might work: <message-resources parameter="Application" />
>
> An example of the dot notation would be:
> <message-resources parameter="org.myco.properties.ApplicationResource s" />
> and then the file would live in:
> /WEB-INF/classes/org/myco/properties/ApplicationResources.properties
>
> HTH,

 
Reply With Quote
 
Wendy S
Guest
Posts: n/a
 
      10-01-2003

"Hari Om" <(E-Mail Removed)> wrote in message > My struts.xml file has:
> <message-resources parameter="ApplicationResources.properties" />


Get rid of the ".properties" part from this one.

The way you have it, I think Struts will look for a file called
properties.properties in the /WEB-INF/classes/ApplicationResources
directory.

Instead of feeling your way around, take a look at the struts-example
webapp. Drop struts-example.war into your container, and examine the config
files for a working webapp.

--
Wendy in Chandler, AZ


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
py2app question: Resources/Python -> Resources/lib/python2.4 Russell E. Owen Python 0 09-08-2006 08:08 PM
Assembly with USER controls (ascx) cannot find its resources mschep@deloitte.nl ASP .Net 0 03-14-2006 11:07 AM
Replace Tab Key to Return Key (Enter Key) from Web Forms? M P ASP General 1 08-06-2004 08:32 AM
Cannot find message resources under key org.apache.struts.action.MESSAGE Joos Nielsen Java 2 06-03-2004 11:30 PM



Advertisments