The following patch has worked for us:
DatabaseRegistry.java
50a51,53
> import java.net.URL;
> import java.net.MalformedURLException;
> import java.io.File;
241a245
>
264c268,284
< mapping.loadMapping( (
(org.exolab.castor.jdo.conf.Mapping) mappings.nextElement() ).getHref() );
---
> {
> // SK : patching castor to correctly resolve relative file
>paths
> String url = ((org.exolab.castor.jdo.conf.Mapping)
mappings.nextElement()).getHref();
> try
> {
> new URL(url);
> }
> catch (MalformedURLException e)
> {
> if(!new File(url).isAbsolute())
> {
> String base = new
File(source.getSystemId()).getParent();
> url = new File(base,url).toString();
> }
> }
> mapping.loadMapping(new InputSource(url));
> }
This will look for the mapping.xml file in the same directory as the
database.xml. It also works for database/mapping.xml files within ear or
war files.
-shehryar
-----Original Message-----
From: Jakob Praher [mailto:[EMAIL PROTECTED]]
Sent: Saturday, March 09, 2002 7:21 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] base location for mapping relative to database
configuration?
hi all,
My System:
GNU/Linux
IBM JDK 1.3
Castor 0.9.3.9
Problem:
When I try to load the database configuration from, for instance,
conf/database.xml
and the mapping.xml is also referenced relative, castor tries to load
the mapping.xml from
${the_dir_where_java_vm_was_started}/mapping.xml
and not from
conf/mappping.xml
but I think relative URLs for mappings should be relative to the
database.xml as the deployer doesn't know in which base directory the
java application runs.
while reading the source I encountered a setBaseURL inside the mapping
package, which castor takes from the SystemID passed to
loadConfiguration, but that has not helped.
while I currently change the InputStream for database.xml on the fly and
feed the changed xml bytes into castor, the problem starts to get worse
if I include several mappings through mapping.xml/mapping/include
element, which is again relative to the java-vm-base-dir.
has anybody a solution for this - is this the right behaviour anyway or
have I missed something?
thanks for your help
--Jakob
-----------------------------------------------------------
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