You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard Morris <rm...@shaw.ca> on 2003/11/10 04:48:28 UTC

Hello World gone wrong

Hi,

I was wondering if someone could help me with this problem that I have.
I am trying to get a simple Hello World struts application to run and I
keep getting this error:

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

I have tried running the web application under these two configurations:
   Tomcat Version: Apache Tomcat/4.1.29
   JVM Version: 1.4.2_02-b03
   JVM Vendor: Sun Microsystems Inc.
   OS Name: Windows XP (Pro)
   OS Versin: 5.1
   OS Architecture: x86
and
   Tomcat Version: Apache Tomcat/4.1.27
   JVM Version: 1.4.2_01-b06
   JVM Vendor: Sun Microsystems Inc.
   OS Name: Linux (Red Hat 9)
   OS Versin: 2.4.20-8smp
   OS Architecture: i386

I get the same error message under both versions.  I have tried searching
the Internet for reasons as to why this would occur.  I have tried putting
the properties file in a package and jar'ing it up and using that to
reference the resource bundle, and I received the same error message.

If I don't use the bean:message to output the keys of the resource
bundle and simply use the html:html and html:base, the output works fine.
The minute I try to use a resource bundle, then I get the error message.
It is almost as though the bean can't find the resource bundle at all.

If anyone can help me or see something that I am missing, I would
really appreciate it.

Thanks.

---------------------------------------------------------------------
Here is the directory structure of the web application:
/hello.jsp
/WEB-INF/web.xml
/WEB-INF/struts-config.xml
/WEB-INF/classes/HelloWorldMessageResources.properties
/WEB-INF/lib/struts.jar
/WEB-INF/tlds/struts-bean.tld
/WEB-INF/tlds/struts-html.tld

---------------------------------------------------------------------
Here is the hello.jsp file:
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>

<html:html>
  <head>
    <title><bean:message key="title.helloworld"/></title>
    <html:base/>
  </head>
  <body>
    <h1><bean:message key="label.helloworld"/></h1>
  </body>
</html:html>

---------------------------------------------------------------------
Here is the struts-config.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config
    PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    
<struts-config>
  <message-resources parameter="HelloWorldMessageResources" null="false"/>
</struts-config>

---------------------------------------------------------------------
Here is the web.xml file:
<?xml version="1.0"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
  <display-name>Hello World Application</display-name>
  
  <description>
    This application simply displays the phrase "Hello World!"
  </description>
  
  <servlet>
    <servlet-name>helloworld</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>application</param-name>
      <param-value>HelloWorldMessageResources</param-value>
    </init-param>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
  </servlet>
  
  <welcome-file-list>
    <welcome-file>hello.jsp</welcome-file>
  </welcome-file-list>
  
  <taglib>
    <taglib-uri>/WEB-INF/tlds/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/WEB-INF/tlds/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location>
  </taglib>
</web-app>

---------------------------------------------------------------------
Here is the HelloWorldMessageResources.properties file:
# Page Titles
title.helloworld=Hello World

# Labels
label.helloworld=Hello World!


Richard Morris
rmmorris@shaw.ca


Re: Hello World gone wrong

Posted by Richard Morris <rm...@shaw.ca>.
Hi Adam,

The HelloWorldMessageResources.properties file is where you have stated.  I
also tried your comment style in the properties file as well as removing all
comments and it didn't change anything.  I have also removed the application
init-param from the web.xml file.

As for the webapp DTD version, you are right about that.  I had the wrong
DTD in there and so modified it.  Here are the DTDs I am using for both the
web.xml and struts-config.xml files:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN"
                         "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"

"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

As for the versions of tomcat and struts, I am using struts 1.1 (the one
currently available for download from their web site).  As for the tomcat
versions, I have tried to run them under the following configurations:

   Tomcat Version: Apache Tomcat/4.1.29
   JVM Version: 1.4.2_02-b03
   JVM Vendor: Sun Microsystems Inc.
   OS Name: Windows XP (Pro)
   OS Version: 5.1
   OS Architecture: x86
and
   Tomcat Version: Apache Tomcat/4.1.27
   JVM Version: 1.4.2_01-b06
   JVM Vendor: Sun Microsystems Inc.
   OS Name: Linux (Red Hat 9)
   OS Version: 2.4.20-8smp
   OS Architecture: i386

You are right about it being a simple app.  I started with just a JSP page
with plain html, then I added the html taglib.  Everything worked fine but
when I tried to use the bean taglib to use resource bundles, that's when I
got this error.

Would there be any changes that I would need to make to the tomcat
server.xml configuration file to get this to work?  I am just using the
default configuration file with the added <Context path="/HelloWorld"
reloadable="true" docBase="E:\Projects\HelloWorld" />.

Anyway, thanks for whatever help you can send my way.

Richard Morris
rmmorris@shaw.ca


----- Original Message ----- 
From: "Adam Hardy" <ah...@cyberspaceroad.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, November 10, 2003 2:01 PM
Subject: Re: Hello World gone wrong


> Hi Richard, you don't need to package it. I have never packaged a
> resources file or put it in a jar seperately. According to your config,
> it's in the right place, something like
>
e:\projects\helloworld\WEB-INF\classes\HelloWorldMessageResources.properties
> right? The error must lie elsewhere.
>
> I can't see why. Your app is so simple, it's got to be a gotcha.
>
> Perhaps the comments in the file are not allowed - I always use
> /* comment */
>
> Also, that action servlet parameter 'application' is deprecated, I think.
>
> You could put this in the struts-config message-resources node:
>
> factory="org.apache.struts.util.PropertyMessageResourcesFactory"
>
> BTW what version of struts and tomcat are you using? I see you've got a
> reference to the webapp_2.2 dtd in your web.xml. I don't suppose you can
> upgrade to at least have a servlet 2.3 container?
>
>
> Adam
>
>
> On 11/10/2003 09:49 PM Richard Morris wrote:
> > I do have the properties file located in the /WEB-INF/classes directory.
> > When I couldn't get it to work using this method, I tried putting the
> > properties into a package and then jar'ed it and put the jar in the
> > /WEB-INF/lib directory.  It still couldn't find the properties file.
> >
> > I am using the default tomcat configuration with the following
server.xml
> > addition:
> > <Context path="/HelloWorld" reloadable="true"
> > docBase="E:\Projects\HelloWorld" />
> >
> > ----- Original Message ----- 
> > From: "Adam Hardy" <ah...@cyberspaceroad.com>
> >>On 11/10/2003 04:48 AM Richard Morris wrote:
> >>>org.apache.jasper.JasperException:
> >>>Cannot find message resources under key
org.apache.struts.action.MESSAGE
> >>>
> >>>Here is the struts-config.xml file:
> >>><struts-config>
> >>>  <message-resources parameter="HelloWorldMessageResources"
> > null="false"/>
> >>></struts-config>
> >>>
> >>>---------------------------------------------------------------------
> >>>Here is the web.xml file:
> >>>  <servlet>
> >>>    <servlet-name>helloworld</servlet-name>
> >>>
> > <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> >
> >>>    <init-param>
> >>>      <param-name>application</param-name>
> >>>      <param-value>HelloWorldMessageResources</param-value>
> >>>    </init-param>
> >>>    <init-param>
> >>>      <param-name>config</param-name>
> >>>      <param-value>/WEB-INF/struts-config.xml</param-value>
> >>>    </init-param>
> >>>  </servlet>
> >>>
> >>>---------------------------------------------------------------------
> >>>Here is the HelloWorldMessageResources.properties file:
> >>># Page Titles
> >>>title.helloworld=Hello World
> >>>
> >>># Labels
> >>>label.helloworld=Hello World!
> >>
> >>Have you got your HelloWorldMessageResources.properties file deployed in
> >>the WEB-INF/classes directory? That is where you have specified that it
> >>is, since you have given no path to such as org.myapp.HelloWorldMess...
>
>
> -- 
> struts 1.1 + tomcat 5.0.12 + java 1.4.2
> Linux 2.4.20 RH9
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: Hello World gone wrong

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi Richard, you don't need to package it. I have never packaged a 
resources file or put it in a jar seperately. According to your config, 
it's in the right place, something like 
e:\projects\helloworld\WEB-INF\classes\HelloWorldMessageResources.properties 
right? The error must lie elsewhere.

I can't see why. Your app is so simple, it's got to be a gotcha.

Perhaps the comments in the file are not allowed - I always use
/* comment */

Also, that action servlet parameter 'application' is deprecated, I think.

You could put this in the struts-config message-resources node:

factory="org.apache.struts.util.PropertyMessageResourcesFactory"

BTW what version of struts and tomcat are you using? I see you've got a 
reference to the webapp_2.2 dtd in your web.xml. I don't suppose you can 
upgrade to at least have a servlet 2.3 container?


Adam


On 11/10/2003 09:49 PM Richard Morris wrote:
> I do have the properties file located in the /WEB-INF/classes directory.
> When I couldn't get it to work using this method, I tried putting the
> properties into a package and then jar'ed it and put the jar in the
> /WEB-INF/lib directory.  It still couldn't find the properties file.
> 
> I am using the default tomcat configuration with the following server.xml
> addition:
> <Context path="/HelloWorld" reloadable="true"
> docBase="E:\Projects\HelloWorld" />
> 
> ----- Original Message ----- 
> From: "Adam Hardy" <ah...@cyberspaceroad.com>
>>On 11/10/2003 04:48 AM Richard Morris wrote:
>>>org.apache.jasper.JasperException:
>>>Cannot find message resources under key org.apache.struts.action.MESSAGE
>>>
>>>Here is the struts-config.xml file:
>>><struts-config>
>>>  <message-resources parameter="HelloWorldMessageResources"
> null="false"/>
>>></struts-config>
>>>
>>>---------------------------------------------------------------------
>>>Here is the web.xml file:
>>>  <servlet>
>>>    <servlet-name>helloworld</servlet-name>
>>>
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> 
>>>    <init-param>
>>>      <param-name>application</param-name>
>>>      <param-value>HelloWorldMessageResources</param-value>
>>>    </init-param>
>>>    <init-param>
>>>      <param-name>config</param-name>
>>>      <param-value>/WEB-INF/struts-config.xml</param-value>
>>>    </init-param>
>>>  </servlet>
>>>
>>>---------------------------------------------------------------------
>>>Here is the HelloWorldMessageResources.properties file:
>>># Page Titles
>>>title.helloworld=Hello World
>>>
>>># Labels
>>>label.helloworld=Hello World!
>>
>>Have you got your HelloWorldMessageResources.properties file deployed in
>>the WEB-INF/classes directory? That is where you have specified that it
>>is, since you have given no path to such as org.myapp.HelloWorldMess...


-- 
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9


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


Re: Hello World gone wrong

Posted by Richard Morris <rm...@shaw.ca>.
Adam,

I do have the properties file located in the /WEB-INF/classes directory.
When I couldn't get it to work using this method, I tried putting the
properties into a package and then jar'ed it and put the jar in the
/WEB-INF/lib directory.  It still couldn't find the properties file.

I am using the default tomcat configuration with the following server.xml
addition:
<Context path="/HelloWorld" reloadable="true"
docBase="E:\Projects\HelloWorld" />

Richard Morris
rmmorris@shaw.ca


----- Original Message ----- 
From: "Adam Hardy" <ah...@cyberspaceroad.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, November 10, 2003 3:47 AM
Subject: Re: Hello World gone wrong


> On 11/10/2003 04:48 AM Richard Morris wrote:
> > org.apache.jasper.JasperException:
> > Cannot find message resources under key org.apache.struts.action.MESSAGE
> >
> > Here is the struts-config.xml file:
> > <struts-config>
> >   <message-resources parameter="HelloWorldMessageResources"
null="false"/>
> > </struts-config>
> >
> > ---------------------------------------------------------------------
> > Here is the web.xml file:
> >   <servlet>
> >     <servlet-name>helloworld</servlet-name>
> >
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> >     <init-param>
> >       <param-name>application</param-name>
> >       <param-value>HelloWorldMessageResources</param-value>
> >     </init-param>
> >     <init-param>
> >       <param-name>config</param-name>
> >       <param-value>/WEB-INF/struts-config.xml</param-value>
> >     </init-param>
> >   </servlet>
> >
> > ---------------------------------------------------------------------
> > Here is the HelloWorldMessageResources.properties file:
> > # Page Titles
> > title.helloworld=Hello World
> >
> > # Labels
> > label.helloworld=Hello World!
>
> Have you got your HelloWorldMessageResources.properties file deployed in
> the WEB-INF/classes directory? That is where you have specified that it
> is, since you have given no path to such as org.myapp.HelloWorldMess...
>
> HTH
> Adam
>
> -- 
> struts 1.1 + tomcat 5.0.12 + java 1.4.2
> Linux 2.4.20 RH9
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: Hello World gone wrong

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
On 11/10/2003 04:48 AM Richard Morris wrote:
> org.apache.jasper.JasperException:
> Cannot find message resources under key org.apache.struts.action.MESSAGE
> 
> Here is the struts-config.xml file:
> <struts-config>
>   <message-resources parameter="HelloWorldMessageResources" null="false"/>
> </struts-config>
> 
> ---------------------------------------------------------------------
> Here is the web.xml file:
>   <servlet>
>     <servlet-name>helloworld</servlet-name>
>     <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>     <init-param>
>       <param-name>application</param-name>
>       <param-value>HelloWorldMessageResources</param-value>
>     </init-param>
>     <init-param>
>       <param-name>config</param-name>
>       <param-value>/WEB-INF/struts-config.xml</param-value>
>     </init-param>
>   </servlet>
> 
> ---------------------------------------------------------------------
> Here is the HelloWorldMessageResources.properties file:
> # Page Titles
> title.helloworld=Hello World
> 
> # Labels
> label.helloworld=Hello World!

Have you got your HelloWorldMessageResources.properties file deployed in 
the WEB-INF/classes directory? That is where you have specified that it 
is, since you have given no path to such as org.myapp.HelloWorldMess...

HTH
Adam

-- 
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9


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