Hi

I was trying a sample program using castor. I am getting error when I
create Unmarshaller object.


try {
                        Mapping      mapping = new Mapping();
                        InputStream ist =
ClassLoader.getSystemClassLoader().getResourceAsStream("mapping2.xml");
            // 1. Load the mapping information from the file
                        InputSource is = new InputSource(ist);
                        
            mapping.loadMapping(is);

            // 2. Unmarshal the data
            Unmarshaller unmar = new Unmarshaller(mapping);
           

        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
            return;
        }

The mapping file is shown at the end of email.

I get 

org.exolab.castor.mapping.MappingException: Nested error: null
null
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:735)
        at
org.castor.mapping.MappingUnmarshaller.loadMappingInternal(MappingUnmars
haller.java:215)
        at
org.castor.mapping.MappingUnmarshaller.getMappingLoader(MappingUnmarshal
ler.java:124)
        at
org.castor.mapping.MappingUnmarshaller.getMappingLoader(MappingUnmarshal
ler.java:99)
        at
org.exolab.castor.xml.Unmarshaller.setMapping(Unmarshaller.java:501)
        at
org.exolab.castor.xml.Unmarshaller.<init>(Unmarshaller.java:254)
        at testwebservice.TestCastor.main(TestCastor.java:33)
Caused by: java.net.MalformedURLException
        at java.net.URL.<init>(URL.java(Compiled Code))
        at java.net.URL.<init>(URL.java:462)
        at java.net.URL.<init>(URL.java:411)
        at
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown
Source)
        at
org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:726)
        ... 6 more

Mapping File

Its  a simple mapping file with 2 classes.

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                         "http://castor.org/mapping.dtd";>
<mapping>
     <class name="testwebservice.TestParent">
        <map-to xml="TestParent"/>
        
        <field name="rowCount">
           <bind-xml name="COUNT" node="attribute"/>
        </field>
        
                
        <field name="name"
           type="java.lang.String">
                <bind-xml name="Name"/>
        </field>
        
        <field name="childlist"
           type="testwebservice.TestChild"
              collection="array">
                <bind-xml name="TestChild"/>
        </field>
     </class>
     
      <class name="testwebservice.TestChild">
               
      <field name="casenum"
           type="java.lang.String">
                <bind-xml name="casenum"/>
        </field>
        
        <field name="mrn"
           type="java.lang.String">
                <bind-xml name="mrn"/>
        </field>
     </class>
</mapping>


Reply via email to