commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Valeri Gavrilovets <valar-l...@mail.ru>
Subject Re: [betwixt] ClassCastException
Date Fri, 12 Nov 2004 14:43:44 GMT
this code 
---------------------- 
      BeanReader beanReader = new BeanReader();
      
      try {
         Object obj = beanReader.parse(file://path-to-xml);

         System.out.println("Object: " + obj);
      } catch (Exception exp) {
         System.out.println("Ignored: " + exp);
        // Here ClassException is catched
      }

      Object obj = beanReader.parse(file://path-to-xml);

      System.out.println("Object: " + obj);
-----------------------
produces by me following output

Ignored: java.lang.ClassCastException
Object: [Request: [ISIN: DE0005140008, ProductType: 2, Amount: 200, OrderId: 1234, OrderType:
BUY, ChannelId: 1, SalesId: 0123456789], Price: null, Response: null, ErrorCode: null, ErrorText:
null]

funny 8-/ 




-----Original Message-----
From: Valeri  Gavrilovets <valar-list@mail.ru>
To: commons-user@jakarta.apache.org
Date: Thu, 11 Nov 2004 21:37:01 +0300
Subject: [betwixt] ClassCastException

> 
> Hi everyone,
> i have some problem by parsing of such xml:
> --------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <Order xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
>   xsi:noNamespaceSchemaLocation='tibco_order.xsd'>
>   <Request>
>     <ISIN>DE0005140008</ISIN>
>     <ProductType>2</ProductType>
>     <Amount>200</Amount>
>     <OrderId>1234</OrderId>
>     <OrderType>BUY</OrderType>
>     <ChannelId>1</ChannelId>
>     <SalesId>0123456789</SalesId>
>   </Request>
> </Order>
> ----------------------
> 
> The class Order:
> ----------------------
> public class Order {
>    private Request  request;
>    private Price    price;
>    private Response response;
>    private String   errorCode;
>    private String   errorText;
> ...
> }
> ------------------
> public class Request {
>    private String     ISIN;
>    private Integer    productType;
>    private BigDecimal amount;
>    private String     orderId;
>    private String     orderType;
>    private Integer    channelId;
>    private String     salesId;
> ...
> }
> ----------------------
> configuration:
> -------------------
>          IntrospectionConfiguration config = _beanReader.getXMLIntrospector().getConfiguration();
>          config.setElementNameMapper(new CapitalizeNameMapper());
> 
>          // register bean classes
>          _beanReader.registerBeanClass(Order.class);
>          _beanReader.registerBeanClass(Request.class);
>          _beanReader.registerBeanClass(Price.class);
>          _beanReader.registerBeanClass(Response.class);
> ------------------
> 
> I get this exception and i have no clue what it tells about =(
> 
> [DEBUG] Digester - -  Fire end() for org.apache.commons.betwixt.io.BeanRuleSet$ActionMappingRule@16546ef
> [ERROR] Digester - -End event threw exception <java.lang.ClassCastException>java.lang.ClassCastException
>         at org.apache.commons.betwixt.io.read.ReadContext.getCurrentElement(ReadContext.java:224)
>         at org.apache.commons.betwixt.io.read.BeanBindAction.update(BeanBindAction.java:164)
>         at org.apache.commons.betwixt.io.read.BeanBindAction.end(BeanBindAction.java:154)
>         at org.apache.commons.betwixt.io.BeanRuleSet$ActionMappingRule.end(BeanRuleSet.java:316)
>         at org.apache.commons.digester.Digester.endElement(Digester.java:1058)
>         at weblogic.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:585)
>         at weblogic.apache.xerces.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:710)
>         at weblogic.apache.xerces.impl.XMLNamespaceBinder.handleEndElement(XMLNamespaceBinder.java:898)
>         at weblogic.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java:644)
>         at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1008)
>         at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1469)
>         at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
>         at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
>         at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
>         at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
>         at weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
>         at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
>         at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:152)
>         at org.apache.commons.digester.Digester.parse(Digester.java:1586)
>         at com.dart.simulator.tibco.TibcoBeanReader.parse(TibcoBeanReader.java:101)
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


http://Mail.Ru - лучшая почта с неограниченным объемом почтового
ящика!

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message