Just a quick little alternate to Stephen's example, see below.

----- Original Message -----
From: "Stephen Bash" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, November 28, 2005 8:15 AM
Subject: Re: [castor-user] Problems with Mapping


> Using the main.java from the link you provided, Castor will look in the
> current working directory for mapping.xml.  If you call java from a
> directory other than where the classes are, Castor won't be able to find
> the mapping file.  You can move the mapping.xml to the directory you
> call java from, or if you plan on keeping your mapping file in the
> classpath, you can look into the getResource method in java.lang.Class
> or java.lang.ClassLoader.  I've had success using these methods as
follows:
>
> myMap.loadMapping(
>     MyDriver.class.getResource( "/castor/examples/map.xml" ) );

When your mapping file is not on the class path you can use a
FileInputStream.

myMap.loadMapping(new  InputSource(
    new FileInputStream(new File("c:/path/castor/examples/map.xml" ))) );
>
> Where my map.xml is in the castor.examples package in the classpath.
> For the getResource call, the "root" directory is the root of the
> classpath rather than the physical filesystem.
>
> Hope that helps,
> Stephen
>
> [EMAIL PROTECTED] wrote:
> > Hi,
> >
> > if I want to start the example from here
> > http://www.castor.org/xml-mapping.html#4.-Usage-Pattern
> >
> > following exception will be thrown
> >
> > java.io.FileNotFoundException: mapping.xmlmapping.xml (Das System kann
> > den angegebenen Pfad nicht finden)
> >
> > Why? The "mapping.xml" is in the same path as the classes.
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>



-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to