Velusamy, I know this is probably going to be a little bit to ask, but could you possibly try and setup a separate, standalone test case that will run outside of struts?
As you know its tough to debug things inside a web-app, and having a small bite size chunk of code that causes the error would be great. This means we would need a small test case, as well as the classes you are trying to marshal. If you could just package everything up in a zip file that would be easist way to handle it. Also, what version of Castor are you using? If its 0.9.5.3 can I suggest you try the release candidate for 0.9.5.4. Its a bug fix release so it shouldn't change any existing constructs you have in your code. -Nick On Wed, 03 Nov 2004 10:34:43 -0500, Velusamy Velu <[EMAIL PROTECTED]> wrote: > Well, I should correct myself before others can understand my statements - I do use > the XML representation of the dropdown list. The items in the dropdown list will be > seen on the user screen and the user can pick an item from the dropdown list. I am > sorry my previous communication was confusing at the best. > > Thanks > > Velusamy K. Velu > (614) 728-0017 > > >>> [EMAIL PROTECTED] 11/03/04 09:40AM >>> > > > I am not sure if I understand what you mean. But to be sure I communicate the > problem - I do not XML representation of the dropdown list. This will be show on > the user screen and user will select an item from the dropdown list. > > Thanks > > Velusamy K. Velu > (614) 728-0017 > > >>> [EMAIL PROTECTED] 11/03/04 09:22AM >>> > > Hello, > Can't you instead generate your castor object straight from > What the database has returned to you? > Is there any particular reason of why you have to go t hru a > Dropdownlist > If you don't use it afterwards? > > Regards > marco > -----Original Message----- > From: Velusamy Velu [mailto:[EMAIL PROTECTED] > Sent: 03 November 2004 14:01 > To: [EMAIL PROTECTED] > Subject: Re: [castor-user] Marshaling issue > > Yes, I could. To isolate the problem I implemented a simple > functionality. There is just one button in the HTML. When it is > clicked the request goes to the TestAction class. The execute method of > the TestAction instantiates the Test class and calls the getStatuses > method. The Test class makes a call to an utility class to get a list > of statuses of vehicles. This list contains only 4 items. However, the > after marshaling it shows locations, makes, models, besides statuses. I > verified that everything is alright until marshaled. After making a > call to marshaller.marshall(object) the contents of vehicleReference is > changed. > > Please let me know if you need additional info. > > Thanks for looking into this problem. > > Here is the action class -- > > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > import org.apache.struts.action.ActionForm; > import org.apache.struts.action.ActionForward; > import org.apache.struts.action.ActionMapping; > import org.jdom.Document; > > import us.oh.state.epa.common.err.AppException; > import us.oh.state.epa.common.util.Logger; > import us.oh.state.epa.common.util.XMLHelper; > import us.oh.state.epa.motorpool.business.Test; > import us.oh.state.epa.motorpool.business.VehicleReference; > import us.oh.state.epa.motorpool.form.TestForm; > > import com.oroad.stxx.action.Action; > > /** > * Test action class. > */ > public class TestAction extends Action > { > > /** > * Handle requests from the vehicle screen. > * > * @see > org.apache.struts.action.Action#execute(org.apache.struts.action.ActionM > apping, > * org.apache.struts.action.ActionForm, > * javax.servlet.http.HttpServletRequest, > * javax.servlet.http.HttpServletResponse) > */ > public ActionForward execute(ActionMapping actionMapping, > ActionForm actionForm, HttpServletRequest > httpServletRequest, > HttpServletResponse response) throws Exception > { > Logger.entering(); > Document document = null; > ActionForward actionForward = > actionMapping.findForward("success"); > TestForm form = (TestForm) actionForm; > int selectedStatusIndex = form.getSelectedStatusIndex(); > > try > { > VehicleReference vehicleReference = new VehicleReference(); > Test test = new Test(); > vehicleReference = test.getStatuses(); // 4 statuses > expected > vehicleReference.changeSelectedStatus(selectedStatusIndex); > document = XMLHelper.convertToXMLDocument(vehicleReference); > } > catch (AppException e) > { > Logger.throwing(e); > document = e.toXML(); > actionForward = actionMapping.findForward("error"); > } > > saveDocument(httpServletRequest, document); > Logger.exiting(); > return actionForward; > } > } > > the minimalized biz logic -- > package us.oh.state.epa.motorpool.business; > > import us.oh.state.epa.common.err.AppException; > import us.oh.state.epa.common.web.DropdownList; > import us.oh.state.epa.motorpool.data.UpdateInsertDataHandler; > > /** > * Test class to isolate the problem with Castor. > */ > public class Test > { > > /** > * Retrieve a list of statuses from the database. > * > * @return VehicleReference > * @throws AppException > */ > public VehicleReference getStatuses() throws AppException > { > VehicleReference vehicleReference = new VehicleReference(); > DropdownList dropdownList = null; > UpdateInsertDataHandler dataHandler = new > UpdateInsertDataHandler(); > dropdownList = dataHandler.getStatus(); > > vehicleReference.setStatuses(dropdownList); > return vehicleReference; > } > } > > data handler > package us.oh.state.epa.motorpool.data; > > import java.util.Hashtable; > > import us.oh.state.epa.common.data.PortableResultSet; > import us.oh.state.epa.common.data.QueryEngine; > import us.oh.state.epa.common.err.AppException; > import us.oh.state.epa.common.util.Logger; > import us.oh.state.epa.common.util.Selectable; > import us.oh.state.epa.common.web.DropdownList; > import us.oh.state.epa.motorpool.Constants; > > /** > * Enter comments to describe this class > */ > public class UpdateInsertDataHandler > { > > public DropdownList getStatus() throws AppException > { > Logger.entering(); > final String QUERY_STRING = "SELECT DISTINCT DESCRIPTION, > STATUS_ID " > + "from motorpool.status " + "where category ='VEHICLE' > "; > > QueryEngine queryEngine = new > QueryEngine(Constants.MOTORPOOL_DATABASE); > PortableResultSet portableResultSet = queryEngine.executeQuery( > QUERY_STRING, null); > > DropdownList descriptionList = new DropdownList(); > Selectable selectable = null; > while (portableResultSet.next()) > { > selectable = new Selectable(); > String description = > portableResultSet.getString("DESCRIPTION"); > String statusID = portableResultSet.getString("STATUS_ID"); > selectable.setItem(description); > selectable.setValue(statusID); > > descriptionList.addSelectable(selectable); > } > Logger.exiting(); > return descriptionList; > } > } > > Thanks > > Velusamy K. Velu > (614) 728-0017 > > >>> [EMAIL PROTECTED] 11/03/04 08:28AM >>> > > Hello there, > Can you post your code? > >From where are you marshalling and unmarshalling? Are you creating > brand new objects or are you marshalling from existing one? > > Regards > marco > > -----Original Message----- > From: Velusamy Velu [mailto:[EMAIL PROTECTED] > Sent: 02 November 2004 18:35 > To: [EMAIL PROTECTED] > Subject: Re: [castor-user] Marshaling issue > > Well, I am not even saving the old XML in a file. It is used by STxx > and thrown away. I also followed the suggestion made by Tim. Tim > suggested that I close the stream to which the XML string was written. > The problem still occurs. > > The source of the problem appears to be the marshaling process changing > the state of the object it marshals. Or, inside the marshal(object) > method an old, stale, cached version of the object is used. To my > amazement I am not sure where, how, when, and which process does the > caching. If I know that I will turn off the caching. Without knowing > that specific information it is not possible to solve this problem. > > Below is the expected XML -- > > <vehicle-reference index="0"> > <statuses index="0"> > <item>AVAILABLE</item> > <value>5</value> > </statuses> > <statuses index="1"> > <item>INUSE</item> > <value>4</value> > <selected>YES</selected> > </statuses> > <statuses index="2"> > <item>OUTFORMAINTENANCE</item> > <value>6</value> > </statuses> > <statuses index="3"> > <item>SALVAGED</item> > <value>7</value> > </statuses> > </vehicle-reference> > > However, I get - > > <vehicle-reference index="0"> > <locations index="0"> > <item>CDO </item> > </locations> > <locations index="1"> > <item>CO </item> > </locations> > > <types index="0"> > <item>VAN</item> > </types> > <types index="0"> > <item>SUV</item> > </types> > > <statuses index="0"> > <item>AVAILABLE</item> > <value>5</value> > </statuses> > <statuses index="1"> > <item>INUSE</item> > <value>4</value> > </statuses> > <statuses index="2"> > <item>OUTFORMAINTENANCE</item> > <value>6</value> > </statuses> > <statuses index="3"> > <item>SALVAGED</item> > <value>7</value> > </statuses> > > <models index="0"> > <item>ASTRO</item> > </models> > <models index="0"> > <item>C-2500</item> > </models> > > <makes index="0"> > <item>CHEV</item> > </makes> > <makes index="0"> > <item>FORD</item> > </makes> > </vehicle-reference> > > that's wrong. > > Thanks > > Velusamy K. Velu > (614) 728-0017 > > >>> [EMAIL PROTECTED] 11/02/04 12:27PM >>> > > I haven't used the xml side of castor greatly, but have you tried > deleting the old xml file, and then marshaling the object again? I > know its kinda a shot in the dark, but since you said the first > marshal worked fine its worth a shot. > > On Tue, 02 Nov 2004 11:07:46 -0500, Velusamy Velu > <[EMAIL PROTECTED]> wrote: > > Hello: > > > > I am continuing to investigate this problem and found the following > additional information - > > > > The type of the object to be marshaled is VehicleReference > > public class VehicleReference extends Selectable > > { > > private ArrayList types = null; > > private ArrayList models = null; > > private ArrayList makes = null; > > private DropdownList statuses = null; > > private DropdownList locations = null; > > private String license = null; > > ... > > } > > To isolate and repeat the problem only the statuses is populated. All > other attributes left in null state. The statuses is of type > DropdownList which extends the java.util.ArrayList and adds a couple of > more functionalities. > > > > In debug mode while stepping through the code the object (an instance > of VehicleReference) is good until the marshaller.marshall(object) > method is called. > > > > state of the object before calling - > > public class VehicleReference extends Selectable > > { > > private ArrayList types = null; > > private ArrayList models = null; > > private ArrayList makes = null; > > private DropdownList statuses = DropdowList (id=305) > > private DropdownList locations = null; > > private String license = null; > > ... > > } > > > > state of the object after that call > > public class VehicleReference extends Selectable > > { > > private ArrayList types = DropdowList (id=306) > > private ArrayList models = DropdowList (id=304) > > private ArrayList makes = DropdowList (id=303) > > private DropdownList statuses = DropdowList (id=305) > > private DropdownList locations = DropdowList (id=302) > > private String license = null; > > ... > > } > > > > The values assigned during the marshaling process to types, models, > makes, and locations are all from a previous run (about 3 days old) of > the program. All of those values are accurate values but not wanted > now. > > > > The result of this is the XML produced is incorrect. > > > > I could see that the old object has been cached. But by which > process? and why it does not refresh? and why it overrides the current > state of the object? Why this happens only with the objects that are in > collections (ArrayList or Vector)? > > > > Your help would be greatly appreciated. > > > > My previous email is truncated in the interest of keeping this thread > relatively clean. > > > > > > Thanks > > > > Velusamy K. Velu > > (614) 728-0017 > > > > >>> [EMAIL PROTECTED] 11/02/04 08:46AM >>> > > Hello: > > > > We are a developing a J2EE based web application. The combination of > Struts and STxx is used to > > . > > . > > > > > > . > > > > I wonder if anyone ran into this kind of problem. Any pointers would > greatly help us. We have been spending about 4 days fruitlessly on this > problem. I can provide more code snippets if necessary. > > > > Thanks > > > > Velusamy K. Velu > > (614) 728-0017 > > > > > > ----------------------------------------------------------- > > If you wish to unsubscribe from this mailing, send mail to > > [EMAIL PROTECTED] with a subject of: > > unsubscribe castor-user > > > > > > > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-user > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-user > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-user > > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-user > > > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-user
