Hi Derek,
 
I've tried this but nothing has changed. I guess then I have not constructed my mapping file in the proper way(?).
 
Thanks a lot,
 
Christos
----- Original Message -----
Sent: Saturday, March 27, 2004 7:14 PM
Subject: Re: [castor-dev] Mapping Trouble ("could not find a class...")

Looks like you're not using the mapping file, try:
 
Mapping map=new Mapping();
map.loadMapping("mapping.xml");
File file = new File("qosProfile.xml");
 
Writer writer = new FileWriter(file);
Marshaller marshaller=new Marshaller(writer);
marshaller.setMapping(map);
marshaller.marshal(qp);  // CHANGE MADE HERE.
 
-derek
-----Original Message-----
From: Christos Gkikas [mailto:[EMAIL PROTECTED]
Sent: Saturday, March 27, 2004 9:59 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Mapping Trouble ("could not find a class...")

 
Hi,
 
I'm using Castor 0.9.5.2 and I'm facing the following problem:
 
I try to export to an XML file an object named QosProfile which is a collection of objects named UmtsQos:
 
QosProfile:
 
public class QosProfile {
//
 private ArrayList listUmtsQos;
//
 public QosProfile()
 {
  listUmtsQos = new ArrayList();
 }
//
 public ArrayList getUmtsQos(){
 
  return listUmtsQos;
 }
//
 public void add(UmtsQos umts){
//
  listUmtsQos.add(umts);
 }
//
  public void remove(UmtsQos umts){
//
  listUmtsQos.remove(umts);
 }
//
}
 
where UmtsQos is a simple class with a simple constructor and setXXX / getXXX methods containing the following attributes :
 
 public int trafficClass;
 public int maxBer;
 
  • The mapping I use is the following :
 
 
<!DOCTYPE databases PUBLIC 
 "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
 "mapping.dtd">
<mapping>
  <description>QosProfile mapping example</description>
   <class name="QosProfile">
    <field name="umtsqos" type="UmtsQos" collection="collection">
      <bind-xml name="umtsqos"/>
    </field>
    </class>
  <class name="UmtsQos" auto-complete="true">
       <field name="trafficClass">
          <bind-xml name="trafficClass" node="attribute"/>
      </field>
      <field name="maxBer">
          <bind-xml name="maxBer" node="attribute"/>
      </field>
 </class>
</mapping>
 
 
  • and the test program :
public class TestQosProfileXML
{
    public static void main(String[] argv) {
  
// build a test bean based on QosProfile class
    QosProfile qp=new QosProfile();
 
  UmtsQos umts = new UmtsQos();
  umts.setMaxBer(5);
  umts.setTrafficClass(2);   
 
 UmtsQos umts2 = new UmtsQos();
  umts2.setMaxBer(15);
  umts.setTrafficClass(12);   
    
  qp.add(umts);
  qp.add(umts2);
  
  try {
       
   // write it out as XML 
   Mapping map=new Mapping();
   map.loadMapping("mapping.xml");
   File file = new File("qosProfile.xml");
  
    Writer writer = new FileWriter(file);
   Marshaller marshaller=new Marshaller(writer);
   marshaller.setMapping(map);
   Marshaller.marshal(qp,writer);
   
                      
     
    } catch (FileNotFoundException ex) {
            ex.printStackTrace(System.err);
    }  catch (IOException ex) {
            ex.printStackTrace(System.err);
    } catch (MarshalException ex) {
            ex.printStackTrace(System.err);
        } catch (MappingException ex) {
            ex.printStackTrace(System.err);
        }catch (ValidationException ex) {
            ex.printStackTrace(System.err);
  }
   }
}
 
 
When I run the test program I get several errors:
 
org.exolab.castor.mapping.MappingException: Could not find the class QosProfile
 at org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(MappingLoader.java:399)
 at org.exolab.castor.xml.XMLMappingLoader.createDescriptor(XMLMappingLoader.java:192)
 at org.exolab.castor.mapping.loader.MappingLoader.loadMapping(MappingLoader.java:289)
 at org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:291)
 at org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:246)
 at org.exolab.castor.xml.Marshaller.setMapping(Marshaller.java:512)
 
at gr.uoa.di.cnl.test.TestQosProfileXML.main(TestQosProfileXML.java:69) ---------------------------> marshaller.setMapping(map);
 
 
        Any directions would be of great help .
        Thank you,
 
       Christos Gkikas


This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so. Thank you.

Reply via email to