The reason the mapping seems to have no effect is because the "marshal"
method you are calling has no access to the mapping, it's a static
method. Please see my response to your other thread which shows an
example on how to correctly call the marshaller.

--Keith


"Krishnasamy, Sathya" wrote:
> 
> Thanks Keith,
> 
> That infact was the problem., the java prefix I thought was castor
> semantics.
> Now the class loads up right, but the mapping does not seem to take effect.
> I do not know what I am missing. I am forwarding u a mail that I sent to the
> group.
> Help would be appreciated.
> 
> Thanks,
> Sathya
> 813 - 209 - 2238
> 
> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 08, 2003 6:09 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] Mapping Exception: setMapping Call not finding
> the application class.
> 
> Hi Sathya,
> 
> Remove the "java:" from the classname and it should work for you.
> 
> --Keith
> 
> "Krishnasamy, Sathya" wrote:
> >
> > Team,
> >
> > I am getting the exception on the line marked in Red. If I comment that
> > line, the marshalling works ( wothout the mapping info). But if I include
> > the mapping, I get the error.
> >
> > The class being referenced in part of an application jar file called
> > common.jar, and is available in the same dir as Test.java
> >
> > The classpath entry shows that the common.jar is set in the classpath.
> >
> > C:\Projects\cvswork\vssweb\castorTest>dir
> >  Volume in drive C has no label.
> >  Volume Serial Number is 8C9E-8ADB
> >
> >  Directory of C:\Projects\cvswork\vssweb\castorTest
> >
> > 09/08/2003  05:26p      <DIR>          .
> > 09/08/2003  05:26p      <DIR>          ..
> > 06/03/2003  03:30p           1,141,033 castor-0.9.5-xml.jar
> > 06/03/2003  03:30p           1,613,261 castor-0.9.5.jar
> > 09/08/2003  04:49p                 255 castor.properties
> > 09/08/2003  04:49p                 255 castor.properties.bak
> > 09/08/2003  04:51p              24,560 common.jar
> > 09/08/2003  10:27a               2,567 Copy of vssmapping.xml
> > 07/30/2003  03:47a             445,345 dom4j.jar
> > 09/08/2003  05:25p                 296 runTest.cmd
> > 09/08/2003  05:26p                 150 setEnv.cmd
> > 09/08/2003  05:25p                 296 setEnv.cmd.bak
> > 09/08/2003  05:26p               2,366 Test.class
> > 09/08/2003  05:13p               2,756 Test.java
> > 09/08/2003  05:12p               2,756 Test.java.bak
> > 09/08/2003  04:07p                 538 vssmapping.xml
> > 09/08/2003  04:04p                 538 vssmapping.xml.bak
> >               15 File(s)      3,236,972 bytes
> >                2 Dir(s)  27,528,147,456 bytes free
> >
> > C:\Projects\cvswork\vssweb\castorTest>set classpath
> > classpath =
> >
> ;./castor-0.9.5-xml.jar;./castor-0.9.5.jar;./common.jar;./dom4j.jar;c:\xmlli
> > bs\lib\crims
> > on.jar;c:\xmllibs\lib\xerces.jar;.;
> >
> > C:\Projects\cvswork\vssweb\castorTest>
> >
> > Do I need any additional configuration ?
> >
> > Help would be appreciated.
> >
> > Thanks,
> > Sathya
> >
> > org.exolab.castor.mapping.MappingException: Could not find the class
> > java:com.cpships.vss.schedule.S
> > chedule
> >         at
> >
> org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(MappingLoade
> > r.java:341)
> >         at
> >
> org.exolab.castor.xml.XMLMappingLoader.createDescriptor(XMLMappingLoader.jav
> > a:192)
> >         at
> >
> org.exolab.castor.mapping.loader.MappingLoader.loadMapping(MappingLoader.jav
> > a:233)
> >         at org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:291)
> >         at org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:246)
> >         at
> org.exolab.castor.xml.Marshaller.setMapping(Marshaller.java:512)
> >         at Test.test(Test.java:56)
> >         at Test.main(Test.java:74)
> >
> > Test.java
> >
> > import java.util.*;
> > import org.xml.sax.ContentHandler;
> > import org.exolab.castor.xml.Marshaller;
> > import org.exolab.castor.mapping.Mapping;
> > import org.apache.xml.serialize.*;
> >
> > import com.cpships.vss.schedule.Schedule;
> > import com.cpships.vss.domain.Port;
> > import com.cpships.vss.domain.PortStop;
> >
> > import java.io.*;
> > import java.net.*;
> >
> > public class Test
> > {
> >     public static final String mappingFile = "vssmapping.xml";
> >
> >         public void test() throws Exception{
> >
> >                 System.out.println(" ............  1 ");
> >
> >                         System.out.println(" ............  2 ");
> >
> >                                 //Mapping castorMapping = new
> > Mapping(getClass().getClassLoader());
> >                                 Mapping castorMapping = new Mapping();
> >
> >                 System.out.println(" ............  3  mapping
> > getClass().getClassLoader()  is " + getClass().getClassLoader() );
> >
> >                                 URL vssMappingURL =
> > getClass().getClassLoader().getResource("vssmapping.xml");
> >                                 System.out.println(" the mapping url
> loaded
> > is "+ vssMappingURL );
> >
> >                                 castorMapping.loadMapping(vssMappingURL);
> >                                 System.out.println(" ............  4 ");
> >
> >                                 StringWriter sw2 = new StringWriter();
> >                                     Marshaller marshaller = new
> > Marshaller(sw2);
> >                                 System.out.println(" ............  5 ");
> >
> >                                 marshaller.setMapping(castorMapping);
> >
> >                                 System.out.println(" ............  6 ");
> >                                 Schedule schedule = new Schedule();
> >                                 schedule.setDirection("E");
> >                                 System.out.println(" Schedule class loader
> > is " + schedule.getClass().getClassLoader());
> >                                 System.out.println(" ............  7  " +
> > schedule.getDirection());
> >                                 marshaller.marshal( schedule, sw2  );
> >                                 String xmlResult = sw2.toString();
> >
> >                 System.out.println( "xmlResult   :::  " + xmlResult );
> >         }
> >
> >     public static void main( String[] args )
> >     {
> >         try
> >         {
> >                                 Test test = new Test();
> >                                 test.test();
> >         }
> >         catch ( Exception except )
> >         {
> >             except.printStackTrace( System.out );
> >         }
> >     }
> > }
> >
> > Mapping file..
> >
> > <?xml version="1.0"?>
> > <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
> > 1.0//EN"
> >                          "http://castor.exolab.org/mapping.dtd";>
> >
> > <mapping>
> >         <class name="java:com.cpships.vss.schedule.Schedule">
> >                 <map-to xml="Schedule"/>
> >
> >                                <field name="direction"
> >                        type="java.lang.String"
> >                        direct="true">
> >                         <bind-xml name="reference" node="attribute"/>
> >                 </field>
> >         </class>
> >
> > </mapping>
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to