commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sol myr <solmyr_...@yahoo.com>
Subject Re: Betwixt: Class cast exception when running example
Date Sun, 17 Apr 2005 16:15:42 GMT
Hi,
 
As you may have seen, i've run into a similar problem. Was surprised to see the aren't many
mentions of it on the web.
 
Just thought I'd mentioned that I've found a temporary workround - at least in my experience,
the problem appears to occur only when BeanReader's Log(ger) is in debug mode ("trace enabled")
. So you may call "BeanReader.setLog()" and give it a Log that doesn't enable tracing [e.g.
make your own implementation of the "Log" interface with  "isTracingEnabled=false". Or create
a  Log4JLogger based on a Logger in Level INFO or WARNING. I expect this can also be controlled
via log4j.properties, but I haven't looked into that last option].
Worked for me, but I'm still waiting for a better solution :(
 
                     Regards


Volker Augustin <volker.augustin@perfektionismus.de> 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("uid='0' login='A'/>");

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


		
---------------------------------
Do you Yahoo!?
 Plan great trips with Yahoo! Travel: Now over 17,000 guides!
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message