commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: Betwixt: Class cast exception when running example
Date Sun, 17 Apr 2005 17:49:05 GMT
this sound like a problem with the 1.6 which has been fixed for a while.
please try again with a recent nightly or roll your own from HEAD.

- robert

On Sun, 2005-04-17 at 12:41 +0200, Volker Augustin wrote:
> Hello,
> 
> I am currently trying  toget Betwixt to work but always get a long list of 
> exceptions.
> 
> java.lang.ClassCastException: java.lang.Class
> 	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:1067)
> 	at 
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
> 	at 
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1241)
> 	at 
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
> 	at 
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> 	at 
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> 	at 
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> 	at 
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> 	at 
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> 	at org.apache.commons.digester.Digester.parse(Digester.java:1610)
> 	at DigesterTest.extractUsingBetwixt(DigesterTest.java:50)
> 	at DigesterTest.main(DigesterTest.java:24)
> 
> The code is copied almost 1 to 1 from the examples, just the classes are 
> different. Any ideas what's wrong? 
> 
> Kind regards,
> Volker
> 
> StringReader xmlReader = new StringReader("<?xml version='1.0' ?><users><user

> uid='0' login='A'/><user uid='1' login='B'/></users>");
>             
> BeanReader beanReader  = new BeanReader();
> beanReader.getXMLIntrospector().setAttributesForPrimitives(false);
> beanReader.setMatchIDs(false);
>             
> beanReader.registerBeanClass("user", User.class);
> beanReader.registerBeanClass("users", Users.class);
>             
> Users users = (Users) beanReader.parse(xmlReader);
>            
> 
> 
> Users.java:
> import java.util.*;
> 
> public class Users {
> 
>     private Set users = new HashSet();
>     
>     public void addUser(User user) {
>         users.add(user);
>     }
>  
>     public User[] getUsers() {
>         return (User[]) users.toArray(new User[0]);
>     }
> }
> 
> 
> 
> User.java:
> public class User {
> 
>     private int uid;
>     private String login;
>     
>     public User() {}
>     
>     public void setUid(int uid) {
>         this.uid = uid;
>     }
> 
>     public void setLogin(String login) {
>         this.login = login;
>     }
>     
>     public int getUid() {
>         return uid;
>     }
>     
>     public String getLogin() {
>         return login;
>     }
> }
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
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