commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sol myr <solmyr_...@yahoo.com>
Subject betwixt 6.0 classCastException
Date Sun, 17 Apr 2005 11:12:29 GMT
Hi,
 
Would anyone please happen to have have information on Betwixt 6.0 throwing ClassCastException
?
 
I'm using Betwixt_0.6 on Websphere 5.1.1 with IBM jdk 1.4.
I run the most basic example (just write a simple bean, then read it), but it crashes.
The trouble appears to be the combination of Betwixt_0.6 + Websphere (my code works fine when
using Betwixt_0.6  +  Sun's jdk 1.4.2,  and when using Betwixt_1a  +  Websphere).
 
                                                                    Thanks very much :)
 
 
The exception is  :
     java.lang.ClassCastException: java.lang.Class
 
Stack trace info:
-    The excpetion is thrown when file position is at EOF (reading the very last closing element)
-    The ClassCastException occurs in ReadContext.getCurrentElement() , line 224:
                     (String) elementMappingStack.peek()  // problematic cast
-    This method was called by BeanBindAction.update(ReadContext, Object) , line 164:

                 if ( updater == null ) ...
                        context.getLog().trace("No updater for " + context.getCurrentElement());
                 // happens even though my class *does* have setter methods
 
My code (very simple):
// bean:
public class Employee implements Serializable{
     private double salary;
     public Employee(){}
     public Employee(double salary) {this.salary=salary;}   
     public double getSalary()  {return salary;}
     public void setSalary(double s)  {salary = s;}
     public String toString() { return "Employee:" + salary;}
}
 
// Write bean to file (this *works*):
Employee emp=new Employee(50000);
FileWriter fout=new FileWriter("c:/aa.xml");
BeanWriter writer=new BeanWriter(fout);
writer.write("emp",emp);
writer.close();
try{fout.close();}catch(Exception ex){}
 
// Then read bean from file (*crashes*):
BeanReader reader=new BeanReader();
FileReader fin=new FileReader("c:/aa.xml");
reader.registerBeanClass("emp",Employee.class);
Object obj=reader.parse(fin);  // crashes
System.out.println(obj);

                                                        thanks again .

                

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