<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I used CVS to get the latest code. Finding the same
problem: I get a "java.lang.ClassCastException: org.jdom.Element" exception when
I try to cast the Attribute object. Below is the XML document, the source
and the exception thrown. Any help would be most appreciated. Thanks, in
advance. -Frank</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>--</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><!--</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Load 2.0 (alpha 1)<BR>(c) 2000 Frank Cohen. All
rights reserved.<BR> This source code is licensed under terms described in
the License.txt file.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Description:<BR> This file contains all
needed configuration information for Load to operate</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>For more info check<BR> <A
href="http://www.inbuilders.com/inbuilders/home.html?igid=G781&rid=R4">http://www.inbuilders.com/inbuilders/home.html?igid=G781&rid=R4</A><BR> or
send email to <A
href="mailto:fcohen@inclusioin.net">fcohen@inclusioin.net</A></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>--></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><load></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> <!--
===================================================================
--><BR> <!-- Initialization
values
--><BR> <!--
===================================================================
--></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> <load_init_values></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> <echo message="Starting Load
2.0 alpha 1"/></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> <property
name="scripts_directory" value="./scripts"/><BR>
<property name="accept_script_versions" value="2"/></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> <property name="log.file"
value="./load.log"/><BR> <property name="log.append"
value="true"/><BR> <property name="log.level"
value="6"/></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> <property name="url"
value=""/><BR> <property name="cookieok"
value="true"/><BR> <property name="bad_string"
value=""/><BR> <property name="timeout"
value="0"/><BR> <property name="sleeptime"
value="0"/><BR> <property name="threadcount"
value="0"/></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> </load_init_values></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></load></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><!-- End of file --></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>--</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><A
href="file://Title:">file://Title:</A>
Load<BR><A
href="file://Version:">file://Version:</A>
2.0<BR><A href="file://Copyright:">file://Copyright:</A> (c)
2000 Frank Cohen. All rights reserved.<BR><A
href="file://Author:">file://Author:</A>
Frank Cohen<BR><A
href="file://Company:">file://Company:</A>
INBuilders.com<BR>//<BR><A
href="file://Description:">file://Description:</A><BR>// Commander executes the
Load script<BR>// the script files is an XML format<BR>// definitions for the
Load script are<BR>// self-documented in this class<BR>//<BR><A
href="file://For">file://For</A> more info check<BR>// <A
href="http://www.inbuilders.com/inbuilders/home.html?igid=G781&rid=R4">http://www.inbuilders.com/inbuilders/home.html?igid=G781&rid=R4</A><BR>//
or send email to <A
href="mailto:fcohen@inclusioin.net">fcohen@inclusioin.net</A><BR>//<BR>// This
source code is licensed under terms described in the License.txt
file.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>package load;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>import java.math.*;<BR>import java.io.*;<BR>import
java.io.IOException;<BR>import java.util.*;<BR>import java.net.*;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>import org.jdom.*;<BR>import
org.jdom.output.XMLOutputter;<BR>import org.jdom.JDOMException;<BR>import
org.jdom.input.SAXBuilder;<BR>import org.jdom.input.DOMBuilder;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /**<BR> *
<p><code>commander</code><BR> * Interprets
the Load script, executes elements<BR> * </p><BR> *<BR> *
@author Frank Cohen<BR> * @version 1.0<BR> */</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>public class commander {</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // Instance of the JDOM XML object for the
Load default settings file<BR> SAXBuilder load_info_builder = new
SAXBuilder();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // loadui object to display the UI
elements<BR> private loadui uiframe;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** Load default setting file name
*/<BR> private static final String default_settings =
"load_info.xml";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>scriptsDir</code>
which directory to find the scripts **/<BR> public String scriptsDir =
"./scripts/";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /**
<code>acceptScriptVersions</code> year of this version **/<BR>
public int acceptScriptVersions = 2;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>logFileName</code> log
file name **/<BR> public String logFileName = "./load.log";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /**
<code>logFileAppendFlag</code> if true, append new log entries to
existing file **/<BR> public boolean logFileAppendFlag =
true;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>logLevel</code>
1-Informational, 6 Ludicrous **/<BR> public int logLevel = 6;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>loadURL</code> base
URL to test **/<BR> public String loadURL = "";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>cookieOk</code> if
true, accept cookies from host **/<BR> public boolean cookieOk =
true;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>badString</code> find
this during a test and abort **/<BR> public String badString =
"";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>timeoutValue</code>
milliseconds to timeout **/<BR> public int timeoutValue =
60000;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>sleepTime</code>
milliseconds to sleep between requests **/<BR> public int sleepTime =
1000;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** <code>threadCount</code>
number of simulated users **/<BR> public int threadCount = 1;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /** Get and keep the reference to the loadui
object */<BR> public void initialize_commander(loadui theframe)<BR>
{<BR> uiframe=theframe;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /**<BR> *
<p><code>echo</code><BR> * Repeats the gaven
String to the log and screen<BR> * </p><BR> */</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> public void echo(String theString)<BR>
{<BR> uiframe.show(theString);<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> public void start()<BR>
{<BR> // Load the entire document into
memory<BR> // from the network or file
system<BR> try<BR>
{<BR> // Gets the Load settings file, parses it
into a DOM tree<BR> Document doc =
load_info_builder.build( default_settings );</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // If there are no
well-formedness errors,<BR> // then no exception
is thrown<BR> uiframe.show( default_settings + "
is well formed.");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // Only read Load setting
files<BR> Element load_set =
doc.getRootElement();<BR> if (
load_set.getName().equals("load") )<BR>
{<BR> // This is a load setting file so parse its
contents</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> loadui.show(
default_settings + " parsing contents");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> //
Within the load element is the load_init_values
group<BR> // These are the elements we
want to set the defaults for Load<BR>
List children =
load_set.getChild("load_init_values").getMixedContent();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> Iterator
iterator = children.iterator();<BR>
while (iterator.hasNext())<BR>
{<BR> Object o =
iterator.next();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> if (o instanceof
Element)<BR>
{<BR> Element
p = (Element) o;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> //
echo elements are comments that get displayed in the
UI<BR> if (
p.getName().equals("echo")
)<BR>
{<BR>
echo( p.getAttribute("message").getValue()
);<BR>
}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> //
property elements are simple name = value pairs that set
a<BR> //
public variable in the commander
object<BR> if (
p.getName().equals("property")
)<BR>
{</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>
List property_list =
p.getAttributes();<BR>
Iterator property_iterator = property_list.iterator();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>
echo( property_list.size() + " = property list size");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>
while ( property_iterator.hasNext()
)<BR>
{<BR>
Object q = iterator.next();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>
Attribute r = (Attribute) q;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>
echo(r.getName());<BR>
echo(r.getValue());</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>
if (q instanceof Attribute) {
echo("attribute");}<BR>
if (q instanceof Element) { echo("element> " + ((Element) q).getName()
);}<BR>
if (q instanceof String) { echo("string");}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>
}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>
}<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
}<BR> else<BR>
{<BR> loadui.show( default_settings + "does
not appear to be a Load settings file");<BR>
}<BR> }<BR> catch (JDOMException e) { //
indicates a well-formedness or other error<BR>
uiframe.show( default_settings + " is not well
formed.");<BR> uiframe.show( e.getMessage()
);<BR> }<BR> }<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>--</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Exception occurred during event
dispatching:<BR>java.lang.ClassCastException:
org.jdom.Element<BR> at
load.commander.start(commander.java:159)<BR>
at
load.loadui.buttonRun_actionPerformed(loadui.java:208)<BR>
at
load.loadui$4.actionPerformed(loadui.java:124)<BR>
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:10<BR>66)<BR>
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra<BR>ctButton.java:1101)<BR>
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel<BR>.java:378)<BR>
at javax.swing.JToggleButton$ToggleButtonModel.setPressed(Compiled
Code)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL<BR>istener.java:217)<BR>
at java.awt.Component.processMouseEvent(Compiled
Code)<BR> at
java.awt.Component.processEvent(Compiled
Code)<BR> at
java.awt.Container.processEvent(Compiled
Code)<BR> at
java.awt.Component.dispatchEventImpl(Compiled
Code)<BR> at
java.awt.Container.dispatchEventImpl(Compiled
Code)<BR> at
java.awt.Component.dispatchEvent(Compiled
Code)<BR> at
java.awt.LightweightDispatcher.retargetMouseEvent(Compiled
Code)<BR> at
java.awt.LightweightDispatcher.processMouseEvent(Compiled
Code)<BR> at
java.awt.LightweightDispatcher.dispatchEvent(Compiled
Code)<BR> at
java.awt.Container.dispatchEventImpl(Compiled
Code)<BR> at
java.awt.Window.dispatchEventImpl(Compiled
Code)<BR> at
java.awt.Component.dispatchEvent(Compiled
Code)<BR> at
java.awt.EventQueue.dispatchEvent(EventQueue.java:258)<BR>
at java.awt.EventDispatchThread.run(EventDispatchThread.java:68)</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>