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

H

Hari Om

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
 
W

Wendy S

Hari Om said:
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.ApplicationResources" />
and then the file would live in:
/WEB-INF/classes/org/myco/properties/ApplicationResources.properties

HTH,
 
H

Hari Om

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.handlePageException(PageContextImpl.java:471)

etc.....
 
W

Wendy S

Hari Om said:
<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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top