I have a small program to unmarshall a XML file (a descriptor) into a class named Component. One of the classes reads the descriptor and does that unmarshalling like this:
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package generator;
 
import org.exolab.castor.xml.*;
import org.exolab.castor.mapping.*;
import java.io.FileReader;
import java.io.*;
import java.util.List;
 
public class DescriptorReader {
   
    private String descriptor;
    private Component c = null;
    private Mapping mapping;
    
    public DescriptorReader(String descFile, String mappingFile) throws Exception  {
        descriptor = descFile;
        mapping = new Mapping();
        mapping.loadMapping(mappingFile);
    }
    
    public void readDescriptor() throws Exception {
       
        Unmarshaller unm = new Unmarshaller(Component.class);
        unm.setMapping(mapping);
       
        FileReader in = new FileReader(descriptor);
        c = (Component) unm.unmarshal(in);
        in.close();
    }
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
The thing is, it worked fine until I put all the classes in a package. I have checked my CLASSPATH and it seems to be OK: I'm not a Java expert, but I get to run the code and it crashes in between saying this:
 
org.exolab.castor.mapping.MappingException: Could not find the class Component
        at org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(Unknown Source)
        at org.exolab.castor.xml.XMLMappingLoader.createDescriptor(Unknown Source)
        at org.exolab.castor.mapping.loader.MappingLoader.loadMapping(Unknown Source)
        at org.exolab.castor.mapping.Mapping.getResolver(Unknown Source)
        at org.exolab.castor.mapping.Mapping.getResolver(Unknown Source)
        at org.exolab.castor.xml.Unmarshaller.setMapping(Unknown Source)
        at generator.DescriptorReader.readDescriptor(DescriptorReader.java:47)
        at generator.Main.main(Main.java:65)
 
What am I doing wrong? Is it really the classpath? Should it say "generator.Component" instead of just "Component"? Help!
Thank you
 
JP

Reply via email to