Your file path (mappingFile) should be relative to the jar location of the 
class being used for getResource.
 

________________________________

From: Herbert Wu [mailto:[EMAIL PROTECTED]
Sent: Wed 01-Nov-06 6:02 PM
To: [email protected]
Subject: [castor-user] how to access mapping files contained in a jar file



Hi, All,

I am stuck with a simple mapping files access issue and here are the details:

I have two mapping files m1.xml and m2.xml placed in foo.jar.
(1) The pkg path to them is com.foo.xml.castor.mapping;
(2) There is include entry in m1.xml
<?xml version="1.0" encoding="UTF-8"?>
<mapping>
    <include href="com/foo/xml/castor/mapping/m2.xml"/>
....
</mapping>

Now, in the client code, foo.jar is included in the class path:

String mappingFile = "com/foo/xml/castor/mapping/m1.xml"
org.exolab.castor.mapping.Mapping mapping= new Mapping();
mapping.loadMapping(this.getClass().getResource(mappingFile));

However the mapping object can not be created with null pointer error.
What's the proper cfg steps to access mapping files in a jar file?

Note: I can run these castor mapping perfectly if the mapping files
are placed in a regular file folder.

Your help is greatly appreciated!
-Herbert

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email






---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to