I'm getting the same error. Would be nice if someone can have a look at this
issue.
Sarry wrote:
>
> I tried every single approach and every single 3rd party tool available to
> generate the mapping files, but I am not able to generate them. I also
> tried with the code given in example and made sure that the class is
> present in the classpath, but still getting the same error.
>
> Here is the code that I got from samples:
>
> /*
>
> * Created on Aug 11, 2004
>
> *
>
> * To change the template for this generated file go to
>
> * Window - Preferences - Java - Code Generation - Code and Comments
>
> */
>
>
>
> import java.io.File;
> import java.io.FileOutputStream;
> import java.io.OutputStream;
> import java.io.OutputStreamWriter;
> import java.io.Writer;
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.exolab.castor.tools.MappingTool;
> import org.exolab.castor.xml.XMLContext;
>
> import com.rac.sims.domain.Person;
>
> /**
> *
> * generate a Castor mapping file ready for editing
> */
>
> public class CastorMapper {
>
> private MappingTool tool = null;
>
> private static Log log = LogFactory.getFactory().getInstance(
> CastorMapper.class);
>
> private static final String OUTPUT_FILE = "product-mapping.xml";
>
> public CastorMapper() {
>
> try {
>
> tool = new XMLContext().createMappingTool();
>
> }
>
> catch (Exception e) {
>
> log.error(e.getClass().getName(), e);
>
> }
>
> }
>
> public void createMapping(Class[] someClasses, String outputFile) {
>
> try {
>
> for (int i = 0; i < someClasses.length; i++) {
>
> tool.addClass(someClasses[i]);
>
> }
>
> File file = new File(outputFile);
>
> log.debug("Output will has been created at "
> + file.getAbsolutePath());
>
> OutputStream stream = new FileOutputStream(file);
>
> Writer writer = new OutputStreamWriter(stream);
>
> tool.write(writer);
>
> writer.close();
>
> }
>
> catch (Exception e) {
>
> log.error(e.getClass().getName(), e);
>
> }
>
> }
>
> public void createMapping(String aClass, String outputFile) {
>
> try {
>
> tool.addClass(aClass);
>
> File file = new File(outputFile);
>
> log.debug("Output will has been created at "
> + file.getAbsolutePath());
>
> OutputStream stream = new FileOutputStream(file);
>
> Writer writer = new OutputStreamWriter(stream);
>
> tool.write(writer);
>
> writer.close();
>
> }
>
> catch (Exception e) {
>
> log.error(e.getClass().getName(), e);
>
> }
>
> }
>
> public static void main(String[] args) {
>
> CastorMapper mapper = new CastorMapper();
>
> mapper.createMapping(Person.class.getName(), OUTPUT_FILE);
>
> }
>
> }
>
> Here is the error I am getting:
>
> 16:42:13 AbstractProperties [DEBUG] Properties loaded from classpath:
> /org/castor/core/castor.core.properties
> 16:42:13 AbstractProperties [DEBUG] Properties loaded from classpath:
> /org/castor/xml/castor.xml.properties
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] New
> instance!
> 16:42:13 XMLContext [DEBUG] Creating new MappingTool instance.
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Get
> descriptor for: com.rac.sims.domain.Person found: null
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Get
> descriptor for: com.rac.sims.domain.Person found: null
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.LoadPackageMappings to value:
> true
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.useIntrospection to value:
> true
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.MappingLoader to value: null
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.Introspector to value:
> org.exolab.castor.xml.Introspector@80fa6f
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.ClassLoader to value:
> sun.misc.Launcher$AppClassLoader@1ba34f2
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.LoadPackageMappings to value:
> true
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.useIntrospection to value:
> true
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.MappingLoader to value: null
> 16:42:13 CastorXMLStrategy [DEBUG] Setting property:
> org.exolab.castor.xml.util.ResolverStrategy.Introspector to value:
> org.exolab.castor.xml.Introspector@80fa6f
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Get
> descriptor for: com.rac.sims.domain.Person found: null
> 16:42:13 AbstractResolverClassCommand [DEBUG] Now in method:
> org.exolab.castor.xml.util.resolvers.ByMappingLoader resolving:
> com.rac.sims.domain.Person
> 16:42:13 ByMappingLoader [DEBUG] No mapping loader specified
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Called
> addAllDescriptors with null or empty descriptor map
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Get
> descriptor for: com.rac.sims.domain.Person found: null
> 16:42:13 AbstractResolverPackageCommand [DEBUG] Now in resolve method:
> org.exolab.castor.xml.util.resolvers.ByCDR resolving: com.rac.sims.domain
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Called
> addAllDescriptors with null or empty descriptor map
> 16:42:13 AbstractResolverPackageCommand [DEBUG] Now in resolve method:
> org.exolab.castor.xml.util.resolvers.ByPackageMapping resolving:
> com.rac.sims.domain
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Called
> addAllDescriptors with null or empty descriptor map
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Get
> descriptor for: com.rac.sims.domain.Person found: null
> 16:42:13 AbstractResolverClassCommand [DEBUG] Now in method:
> org.exolab.castor.xml.util.resolvers.ByDescriptorClass resolving:
> com.rac.sims.domain.Person
> 16:42:13 ResolveHelpers [DEBUG] Ignored problem at loading class:
> com.rac.sims.domain.PersonDescriptor through class loader:
> sun.misc.Launcher$AppClassLoader@1ba34f2, exception:
> java.lang.ClassNotFoundException: com.rac.sims.domain.PersonDescriptor
> 16:42:13 ResolveHelpers [DEBUG] Ignored problem at loading class:
> com.rac.sims.domain.descriptors.PersonDescriptor through class loader:
> sun.misc.Launcher$AppClassLoader@1ba34f2, exception:
> java.lang.ClassNotFoundException:
> com.rac.sims.domain.descriptors.PersonDescriptor
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Called
> addAllDescriptors with null or empty descriptor map
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Get
> descriptor for: com.rac.sims.domain.Person found: null
> 16:42:13 AbstractResolverClassCommand [DEBUG] Now in method:
> org.exolab.castor.xml.util.resolvers.ByIntrospection resolving:
> com.rac.sims.domain.Person
> 16:42:13 AbstractProperties [DEBUG] Properties loaded from classpath:
> /org/castor/core/castor.core.properties
> 16:42:13 AbstractProperties [DEBUG] Properties loaded from classpath:
> /org/castor/xml/castor.xml.properties
> 16:42:13 ByIntrospection [DEBUG] Found descriptor:
> org.exolab.castor.xml.IntrospectedXMLClassDescriptor@12cc95d; descriptor
> for class: com.rac.sims.domain.Person; xml name: null
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Adding
> descriptor class for: com.rac.sims.domain.Person descriptor:
> org.exolab.castor.xml.IntrospectedXMLClassDescriptor@12cc95d; descriptor
> for class: com.rac.sims.domain.Person; xml name: null
> 16:42:13 XMLClassDescriptorResolverImpl$DescriptorCacheImpl [DEBUG] Get
> descriptor for: com.rac.sims.domain.Person found:
> org.exolab.castor.xml.IntrospectedXMLClassDescriptor@12cc95d; descriptor
> for class: com.rac.sims.domain.Person; xml name: null
> 16:42:13 CastorMapper [ERROR] java.lang.IllegalArgumentException
> java.lang.IllegalArgumentException: No enum const class
> org.exolab.castor.mapping.xml.types.BindXmlNodeType.element
> at java.lang.Enum.valueOf(Enum.java:196)
> at
> org.exolab.castor.mapping.xml.types.BindXmlNodeType.valueOf(BindXmlNodeType.java:15)
> at org.exolab.castor.tools.MappingTool.addClass(MappingTool.java:408)
> at org.exolab.castor.tools.MappingTool.addClass(MappingTool.java:222)
> at org.exolab.castor.tools.MappingTool.addClass(MappingTool.java:201)
> at CastorMapper.createMapping(CastorMapper.java:95)
> at CastorMapper.main(CastorMapper.java:124)
>
> If it's not going to be possible to generate like this? do you know any
> other tool that can generate these mapping files for me?
>
--
View this message in context:
http://old.nabble.com/Not-able-to-generate-mapping-files-using-MappingTool-tp33541909p33931621.html
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email