castor.mapping.Mapping
import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.net.URL;
import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.xml.Unmarshaller;
public class XmlToBean {
public Mybean getBean() throws Exception {
Mapping map = new Mapping();
URL u = this.getClass().getClassLoader().getResource("com/my/ioc/config/config-mapping.xml");
map.loadMapping(u);
Unmarshaller un = new Unmarshaller(Mybean.class);
File file = new File("myconfig.xml");
file.getAbsoluteFile();
Reader reader = new FileReader(file);
// Unmarshaller unmarshaller = new Unmarshaller(map);
un.setMapping(map);
Mybean read = (Mybean) un.unmarshal(reader);
return read;
}
}
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.exolab.castor.mapping.Mapping.<clinit>(Mapping.java:70)
at com.my.ioc.config.XmlToBean.getBean(XmlToBean.java:14)