Hey Werner...
After lots of trying different things, I did try to catch a
Throwable instead of an Exception and that works. But, I talked to my
colleagues here at work and we arrived at a consensus that having to
catch a Throwable is a bad design strategy used by Castor. Plus, there
is no way anyone would think/know of catching a Throwable in lieu of an
Exception. The XML that was generated was complete and valid cos I did
use the same XML in a standalone application and it worked fine.
Actually, when I caught Throwable, I figured out that I had not included
Xerces.jar in the Classpath. But, it was a rather strange/long/arduous
path to locate the problem. Is there something that I am missing out on?
Thanks a bunch for all the help.
-Shreeram
Werner Guttmann wrote:
> Shreeram,
>
> can you please try to change your code to catch a Throwable rather
> than an Exception and see whether this makes a difference ? In
> addition, can you please post the out put of the logging statement (if
> that's possible) ? In other words, I'd like to verify that the XML
> that is being received is complete and valid.
>
> Werner
>
> --Original Message Text---
> From: Shreeram Iyer
> Date: Tue, 1 Jul 2003 10:30:10 -0700 (PDT)
>
> Hello...
> Let me put in a nutshell what I have been trying to do. I have
> been playing with a JMS application. What I do is retrieve some data
> from Sybase, form OBJECTS out of it and then MARSHAL the Object tree
> into a XML file. Then, I send this XML data as a TextMessage to a
> Message Driven Bean. In the onMessage() method of the MDB, I print out
>
> the message received. Everything is fine till here. Now, to UNMARSHAL
> the XML back into the Object hierarchy, I create a Reader using
> StringReader(String) and then use UnMarshaller.unmarshal(Class,
> Reader)
> method. This doesn't seem to work. Also, the message is being sent
> back
> to the queue cos it is not being consumed because of some Exception
> being thrown during the Unmarshalling process. I have written code to
> catch any Exception thrown. Surprisingly, the Exception is not caught
> and the Message reappears.
> Has anyone faced a similar problem? Is there something I can do
> to get this working? Thanks a bunch to everyone!!!
> -Shree Iyer
>
> P.S. Here is a snippet of the code...
> This is the piece of code which does the Marshalling and then sends a
> Message to JMS.
> // The Object tree is represented by result
> FileWriter writer = new FileWriter("LoanSelectionUpdate.xml");
> Marshaller.marshal(result, writer);
> System.out.println("Created XML document....");
> BufferedReader buf = new BufferedReader(new
> FileReader("LoanSelectionUpdate.xml"));
> StringBuffer data = new StringBuffer();
> String line = new String();
> while ((line = buf.readLine()) != null)
> {
> data.append(line);
> }
> msg = qSession.createTextMessage();
> msg.setText(data.toString());
> // Sending the message to a JMS queue...
> qSender.send(msg);
>
> This is the piece of code in the MDB within the onMessage() method
> try
> {
> if (message instanceof TextMessage)
> {
> // The String containing the XML content which is to be parsed
> String xmldoc = ((TextMessage) message).getText();
> log.debug("Incoming XML :******************* ");
> // This prints out the right XML document content...
> log.debug(xmldoc);
> System.out.println("About to unmarshal XML document");
> Reader reader = new StringReader(xmldoc);
> try
> {
> // This line doesn't seem to be working...
> LoanSelectionUpdateDTO loanSelectionUpdateDto =
> (LoanSelectionUpdateDTO)
> Unmarshaller.unmarshal(LoanSelectionUpdateDTO.class, reader);
> }
> &nbs!
> p; // If at all an Exception is thrown, it is not being caught
> here...Surprising...!!!
> catch (Exception me)
> {
> me.printStackTrace();
> System.out.println("Exception while unmarshalling... Upper" +
> me.getMessage());
> }
> // It doesn't get here...the onMessage() method returns and tries to
> consume the message again...probably because an Exception was
> thrown...but no clue where!!
>
>
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
>
>
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev