In the application server environment, you might have to do some tricks to 
get the proper ClassLoader which can find your database.xml document.

ClassLoader.getSystemResourceAsStream will use the SystemClassLoader to get a 
stream, which could be different from the classloader that is actually used 
to load your classes.

perhaps you can use the line:

this.getClass().getClassLoader().getResourceAsStream(systemId);

from your EntityResolver implementation. That will make sure that the 
classloader that loaded the EntityResolver can be used to load database.xml 
instead of the System ClassLoader.


On Friday 01 March 2002 09:50 am, Sylvie RAMON wrote:
> Hi,
>
> I "run" slowly in this problem ...
>
> When i use EntityResolver in a simple main() method : It's successfull.
> All xml file are found without indicate physical location.
>
> BUT , with an web application, this failed.
> I use the same method that i use in simple main() method.
> My database.xml is not found!
> The directory wich contain dtabase.xml is in the CLASSPATH.
>
> i don't understand.
>
> Someone has an idea ??
>
> Thanks for your help.
>
> >>> [EMAIL PROTECTED] 01/03/02 10:07:55 >>>
>
> Hi,
>
> I put the directory where there are files castor in CLASSPATH and my
> application finds database.xml using EntityResolver.
>
> That's a good thing.
>
> BUT now, this os the jdo-conf.dtd which is not found!
> and i think, all mapping.xml will not foud too.
>
> I know that i can put an url for jdo-conf.dtd, but I can't access to
> internet from my pc and so i have pb. So I put jdo-conf.dtd in local.
>
> I can't apply EntityResolver in dtabase.xml, so how can i do that ??
>
> Thanks for your help.
> Sylvie
>
>
>
> Thanks at all for your help.
>
> I try the EntityResolter solution, but it failed.
> I have the exception "Unable to resolve entity: .... "
>
> When you write "castortest/database.xml" , is castortest in the classpath
> ??
>
> My castor file are in :
> "root WSAD .../workspace/umm/webApplication/Castor/..xml
>
> There is something i don't understand.
> I continue to search .
>
> Thanks a lot.
>
> >>> [EMAIL PROTECTED] 27/02/02 15:07:54 >>>
>
> I work with VAJ 3.5.2, but I imagine WASD is similar.
>
> I've got the Castor supplied resources in a directory on my classpath.
> c:\Projects\Cim\Resources is on my Workspace classpath, and org\exolab\...
> folders etc are under c:\Projects\Cim\Resources.
>
> For my application specific xml files, I use an EntityResolver with the
> resources on the classpath just like the Castor supplied resources.
>
> Here is how I used the EntityResolver.
>
>       try
>       {
>               lJdo = new JDO();
>               lJdo.setDatabaseName("EMAILD1");
>
>               EmailEntityResolver lEmailEntityResolver = new
> EmailEntityResolver();
>
>               InputSource lDatabaseConfiguration =
>                       lEmailEntityResolver.resolveEntity(null,
> "castortest/database.xml");
>
>               lJdo.loadConfiguration(lDatabaseConfiguration,
> lEmailEntityResolver, null);
>
>               ...
>
> Here is the resolveEntity() method of my EntityResolver.
>
> public org.xml.sax.InputSource resolveEntity(String publicId,
>       String systemId) throws IOException, SAXException
> {
>       InputStream lInputStream =
>               ClassLoader.getSystemResourceAsStream(systemId);
>
>       if (lInputStream != null)
>       {
>               return new InputSource(lInputStream);
>       }
>       else
>       {
>               throw new IOException("Unable to resolve entity: " +
> systemId);
>       }
> }
>
> -----Original Message-----
> From: Sylvie RAMON [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 3:06 AM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] Location of files
>
>
> Hi,
>
> I have an another question and i don't find response .
> I work with WSAD.
>
> With JDo and xml, we have to work with a lot of file  ( xml, dtd, etc.. ) .
> I put these files directly on a subdirecory of my project.
>
> In all my applications, i have to put the physical location of these files
> ( real location "d:\....." or from root of wsad "/workspace/...".
>
> So when an another developper want to work with my application or when i
> deploy application on WAS4, i have problems with the location.
>
> I would like to put a logical location. Is it possible??
> Is there an another solution to that??
> Do i have to put files in a directory out of my projet ??
>
> Thanks for your help.
>
> -----------------------------------------------------------
> 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

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

Reply via email to