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

Discussion in 'Java' started by Hari Om, Sep 30, 2003.

  1. Hari Om

    Hari Om Guest

    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
     
    Hari Om, Sep 30, 2003
    #1
    1. Advertising

  2. Hari Om

    Wendy S Guest

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

    HTH,

    --
    Wendy in Chandler, AZ
     
    Wendy S, Oct 1, 2003
    #2
    1. Advertising

  3. Hari Om

    Hari Om Guest

    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.....
    --------------------------------------------------------------------------------
    Any hints etc on this....?

    THANKS!



    "Wendy S" <> wrote in message news:<bld3du$ght$>...
    > "Hari Om" <> 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.ApplicationResources" />
    > and then the file would live in:
    > /WEB-INF/classes/org/myco/properties/ApplicationResources.properties
    >
    > HTH,
     
    Hari Om, Oct 1, 2003
    #3
  4. Hari Om

    Wendy S Guest

    "Hari Om" <> 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
     
    Wendy S, Oct 1, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page