wood burning stoves 2.0*
The moose likes Struts and the fly likes Deploy time exception - Key Attribute required for element exception 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 "Deploy time exception - Key Attribute required for element exception" Watch "Deploy time exception - Key Attribute required for element exception" New topic
Author

Deploy time exception - Key Attribute required for element exception

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi
i am getting the following exceptions when i deployed my struts application

1) java.lang.NoClassDefFoundError:
org/apache/commons/collections/FastHashMap$KeySet

2) org.xml.sax.SAXParseException:
Attribute "key" is required and must be specified for element type "exception".
--- Is the key attribute requried? i informed it is optional.

Any idea why?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This error would occur if the commons-collections.jar is not in your WEB-INF/lib directory. Make sure that this jar file as well as all other jar files that came with the Struts download are in your WEB-INF/lib directory.


Merrill
Consultant, Sima Solutions
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi
I downloaded struts from apache. but the zip file i downloaded doesn't contains the jar file mentioned by you.

So it would be helpful if you can mention me the link or location where i can find out all the commons-* .jar files (as a bunch), needed for the struts application.

And also i wonder why particular commons=*.jar files are missed in latest version of struts. The latest version i downloaded is 1.2.9. (struts-1.2.9-bin.zip)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Actually, commons-collectins.jar is from an earlier version. If you're using the latest version, the jar file containing the class reported in the error is commons-beanutils.jar.

Another thing that could cause the problem you reported is using a struts.jar file that is from a different version than the commons-xxx.jar files. Make sure they all come from the same download.

I would suggest you re-download the file from here. When you unzip the file, there will be a lib directory. Copy all the jar files in the lib directory to your WEB-INF/lib directory. There will be eight of them:
antlr.jar
commons-beanutils.jar
commons-digester.jar
commons-fileupload.jar
commons-logging.jar
commons-validator.jar
jakarta-oro.jar
struts.jar

An even better way to make sure you have everything you need is to find the struts-blank.war file in the webapps directory, unpack it, and use it as a template for your application.
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
Hi i copied all the jar files from the location mentioned by you.

but the problem is i am getting the below error.

Parsing of JSP File '/reprocessCriteria.jsp' failed:
--------------------------------------------------------------------------------
/reprocessCriteria.jsp(2): Error in using tag library uri='/WEB-INF/tlds/struts-html.tld' prefix='html': The Tag class 'org.apache.struts.taglib.html.FormTag' has no setter method corresponding to TLD declared attribute 'name', (JSP 1.1 spec, 5.4.1)
probably occurred due to an error in /reprocessCriteria.jsp line 2:
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>

i doubt after copying the latest jar files, the tld is in mismatch can you tell me whats the problem and how to fix it.?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I suspect the problem is with your <html:form> tag. In Struts 1.2.9, the name and type attributes of this tag are deprecated. All you need to specify now is "action". You are probably looking at tutorials or instructions that tell you to define a name and type attribute for the <html:form> tag. These were created for earlier versions of Struts. Just remove the name and type attributes and it should work.
[ July 22, 2006: Message edited by: Merrill Higginson ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Deploy time exception - Key Attribute required for element exception
 
Similar Threads
Use of set tag in Hibernate mapping file for foreign key
required false
SAXException
NullPointerException
javax/servlet/jsp/tagext/JspIdConsumer exception in JSF Richfaces