This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Error using Struts Messages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Error using Struts Messages" Watch "Error using Struts Messages" New topic
Author

Error using Struts Messages

Gerome Kawa
Ranch Hand

Joined: Dec 05, 2002
Posts: 61
Hi
I am following the Struts tutorial by Stephen Wiesner . Am just trying to use the bean:message tag in my JSP . But am getting the following error:
- The server encountered an internal error () that prevented it from fulfilling this request.
- org.apache.jasper.JasperException: Cannot find message resources under key org.apache.struts.action.MESSAGE
Note:
My JSP:
##############################################
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<head>
<title><bean:message key="index.title"/></title>
<html:base/>
</head>
<body>
<h2>Book View in body</h2><BR>
<bean:message key="index.title"/>
<bean:message key="kausik.title"/>
</body>
</html:html>
#################################################
web.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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>
<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-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
<!-- Welcome file list -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- Struts Tag Library Descriptor -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
</web-app>
#################################################
struts_config.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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></struts-config>
#################################################
Can anyone please help me overcoem this problem. It is very frustrating to get stuck at the initial stages of a tutorial.
Thanks
Kausik
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Moving to the Struts forum (Frameworks).


"JavaRanch, where the deer and the Certified play" - David O'Meara
George Brown
Ranch Hand

Joined: Sep 26, 2000
Posts: 919
You should have a file in your directory hierarchy called 'applicationResources.properties' and it should have a line in it something like:

along with whatever else you want to include. You should place this file according to the 'application' tag in your web.xml, in yours there is no package prefixing it so the file should be put at the same level as the 'org' and 'com' directories, in WEB-INF/classes within your web application.
HTH.
[ May 02, 2003: Message edited by: George Brown ]
Gerome Kawa
Ranch Hand

Joined: Dec 05, 2002
Posts: 61
Hi George Brown
Thanks for th suggestion. The application resources file is in the proper place (As you mentioned).(Note: i am following the Struts tutorial by Stephan Weisner). But I am still getting the problem.
Any meaningful suggestion will be appreciated.
Cheers
Kausik
Eric Hauser
Greenhorn

Joined: May 13, 2003
Posts: 3
> struts_config.xml
I'm not sure if this was a typo or not, but your this should be struts-config.xml
Also you should insert the following line into your struts-config.xml:
<message-resources parameter="package.ApplicationResources" />
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
May I know where to find Stephen Wiesner's tutorial examples?
Bruno Arantes
Greenhorn

Joined: Apr 30, 2003
Posts: 24
Originally posted by JiaPei Jen:
May I know where to find Stephen Wiesner's tutorial examples?

Stephen Wiesner's tutorial is here in pdf format: Struts Tutorial
Good luck.


Bruno Arantes Bueno.<br />Certified Lotus Specialist, SCJP 1.4.
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Bruno, thanks a lot for the information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error using Struts Messages
 
Similar Threads
help on taglib and properties file in struts?
HTTP Status 500
Failed to load servlet:
Jboss 4.2.3 how to change the default datasource to oracle ?
"/tags/struts-logic" not found