Hi There,
i've justed installed CASTOR and i am trying to work through my first test example and i get the following error:
 
Am i missing anything? Any ideas whats wrong?
my classpath is
 
C:\Java>echo %CLASSPATH%
C:\Java\castor-0.9.6\castor-0.9.6.jar;C:\Java\castor-0.9.6\castor-0.9.6-xml.jar;
C:\Java\castor-0.9.6\castor-0.9.6-srcgen-ant-task.jar;C:\Java\castor-0.9.6\casto
r-0.9.6-xml.jar;C:\Java\castor-0.9.6\jdbc-se2.0.jar;C:\Java\castor-0.9.6\jta1.0.
1.jar;C:\Tomcat\jConnect-5_5\classes\jconn2.jar;C:\Tomcat\jConnect-5_5\classes\j
TDS2.jar;C:\Tomcat\jakarta-regexp-1.3\jakarta-regexp-1.3.jar;\c:\Java;c:\java\ha
ll;c:\sybtools\ASEP\Monclass.zip;c:\sybtools\ASEP\3pclass.zip;
 
C:\Java>java HashTest
#setChildren!
#getChildren!
Here is a key [key1] value [value1]
Here is a key [key2] value [value2]
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xml/serial
ize/XMLSerializer
        at org.exolab.castor.xml.Unmarshaller.initConfig(Unmarshaller.java:272)
        at org.exolab.castor.xml.Unmarshaller.<init>(Unmarshaller.java:225)
        at org.exolab.castor.xml.Unmarshaller.<init>(Unmarshaller.java:212)
        at org.exolab.castor.mapping.Mapping.loadMappingInternal(Mapping.java:52
7)
        at org.exolab.castor.mapping.Mapping.loadMappingInternal(Mapping.java:48
3)
        at org.exolab.castor.mapping.Mapping.loadMapping(Mapping.java:410)
        at HashTest.main(HashTest.java:42)
 
C:\Java>
 
 
 
 
Just for completeness, here's the smaple code i've been given:
 
import java.util.HashMap;
import java.util.Iterator;
import java.util.Collection;
import java.util.Map;
 
import java.io.StringWriter;
import java.io.StringReader;
 
import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.mapping.MappingException;
 
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.Marshaller;
 
import java.io.IOException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
 
import org.xml.sax.InputSource;
 

import java.util.HashMap;
 
public class HashTest {
 
    public static void main(String[] args) {
         
        Root root = new Root();
         
        HashMap map = new HashMap();
        map.put("key1", "value1");
        map.put("key2", "value2");
       
        root.setChildren(map);
       
        testRoot(root);
        Mapping      mapping = new Mapping();
 
        try {
            // 1. Load the mapping information from the file
            mapping.loadMapping( "mapping.xml" );
 
            FileWriter writer = new FileWriter("test.xml");
            // 4. marshal the data with and print the XML in the console
            Marshaller marshaller = new Marshaller(writer);
            marshaller.setMapping(mapping);
            marshaller.marshal(root);
            writer.close();
 
            FileReader reader = new FileReader("test.xml");
            // 2. Unmarshal the data
            Unmarshaller unmar = new Unmarshaller(mapping);
            Root newRoot = (Root)unmar.unmarshal(reader);
 
            testRoot(newRoot);
 
        } catch (Exception e) {
            e.printStackTrace();
        }    
    }
   
    public static void testRoot(Root root) {
        Map kids = root.getChildren();
        for (Iterator itr = kids.keySet().iterator(); itr.hasNext();)
        {
            Object key = itr.next();
            System.out.println("Here is a key [" + key.toString() +
                "] value [" + kids.get(key) + "]");
        }
   
    }
}
 
 
and
 
import java.util.Map;
import java.util.HashMap;
public class Root {
 
  HashMap _children = new HashMap();
 
  public HashMap getChildren() {
    System.out.println("#getChildren!");
      return _children;
  }
  public void setChildren(HashMap m) {
    System.out.println("#setChildren!");
      _children = (HashMap)m;
  }
}
----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to