You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Antonio Fiol Bonnín <an...@gmail.com> on 2004/09/23 20:48:14 UTC

[configuration] How to load from a resource (as opposed to a file)

Hi,

<configuration>
   <hierarchicalDom4j fileName="someFile.xml" />
</configuration>

looks for someFile.xml in the same place as the containing xml. Looks
good... unless the containing XML is a resource.

Possibly due to a bug on ClassLoader implementation in both Tomcat and
IBM WAS, if the containing file is in a jar file in WEB-INF/lib, and
someFile.xml is in the same package (to make it simpler) in
WEB-INF/classes/package/name, the file is not properly loaded, for
different reasons in each App server.

So the question is: Can I state something like...
filename="resource:package/name/someFile.xml" that would ultimately
resolve to the right file in the right place?

Do I have an alternative other than translating the XML into code that
creates the right Configuration objects (in a CompositeConfiguration),
but giving each the right URL I got from Class.getResource(String) ?

Thank you very much.


Antonio Fiol

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [configuration] How to load from a resource (as opposed to a file)

Posted by Eric Pugh <ep...@upstate.com>.
Hum..  Good questions..   I think that I am more suggesting that we need to
be smarter in ConfigurationFactory..

To me, it sees like you should be using a URL to locate it.  Take a looksee
at TestConfigurationUtils.  So, I guess I'm saying I'm not real sure!

Eric

> -----Original Message-----
> From: Antonio Fiol Bonnin [mailto:antonio.fiol@gmail.com]
> Sent: Friday, September 24, 2004 2:20 PM
> To: epugh@upstate.com
> Cc: Jakarta Commons Users List
> Subject: Re: [configuration] How to load from a resource (as opposed to
> a file)
>
>
> Hi Eric,
>
> I am really glad the issue can be solved (and will be).
>
> WRT the unit test, I find it a bit complicated to isolate, but I may
> try to create a few classes for that. But anyway, what I would need to
> know is what the expected behaviour is. In other words: what am I
> supposed to have in the fileName attribute to read from a resource?
>
> Thank you very much.
>
>
> Antonio Fiol
>
>
> On Fri, 24 Sep 2004 13:38:00 +0200, Eric Pugh <ep...@upstate.com> wrote:
> > Hi..
> >
> > I think, and Emmanuel, can you verify for me, that we need to change the
> > ConfigurationFactory to use the new file locating stuff?  Right
> now I think
> > the problem is that in
> ConfigurationFactory.FileConfigurationFactory, the
> > logic for finding a file sucks..  I think the whole basePath is wrong..
> >
> > Antonio, if you could send in a unit test demonstrating this, that would
> > really help verify that any changes we make solve your problem.
> >
> > Eric
> >
> >
> >
> > > -----Original Message-----
> > > From: Antonio Fiol Bonnin [mailto:antonio.fiol@gmail.com]
> > > Sent: Thursday, September 23, 2004 8:48 PM
> > > To: Jakarta Commons Users List
> > > Subject: [configuration] How to load from a resource (as opposed to a
> > > file)
> > >
> > >
> > > Hi,
> > >
> > > <configuration>
> > >    <hierarchicalDom4j fileName="someFile.xml" />
> > > </configuration>
> > >
> > > looks for someFile.xml in the same place as the containing xml. Looks
> > > good... unless the containing XML is a resource.
> > >
> > > Possibly due to a bug on ClassLoader implementation in both Tomcat and
> > > IBM WAS, if the containing file is in a jar file in WEB-INF/lib, and
> > > someFile.xml is in the same package (to make it simpler) in
> > > WEB-INF/classes/package/name, the file is not properly loaded, for
> > > different reasons in each App server.
> > >
> > > So the question is: Can I state something like...
> > > filename="resource:package/name/someFile.xml" that would ultimately
> > > resolve to the right file in the right place?
> > >
> > > Do I have an alternative other than translating the XML into code that
> > > creates the right Configuration objects (in a CompositeConfiguration),
> > > but giving each the right URL I got from Class.getResource(String) ?
> > >
> > > Thank you very much.
> > >
> > >
> > > Antonio Fiol
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [configuration] How to load from a resource (as opposed to a file)

Posted by Antonio Fiol Bonnín <an...@gmail.com>.
Hi Eric,

I am really glad the issue can be solved (and will be).

WRT the unit test, I find it a bit complicated to isolate, but I may
try to create a few classes for that. But anyway, what I would need to
know is what the expected behaviour is. In other words: what am I
supposed to have in the fileName attribute to read from a resource?

Thank you very much.


Antonio Fiol


On Fri, 24 Sep 2004 13:38:00 +0200, Eric Pugh <ep...@upstate.com> wrote:
> Hi..
> 
> I think, and Emmanuel, can you verify for me, that we need to change the
> ConfigurationFactory to use the new file locating stuff?  Right now I think
> the problem is that in ConfigurationFactory.FileConfigurationFactory, the
> logic for finding a file sucks..  I think the whole basePath is wrong..
> 
> Antonio, if you could send in a unit test demonstrating this, that would
> really help verify that any changes we make solve your problem.
> 
> Eric
> 
> 
> 
> > -----Original Message-----
> > From: Antonio Fiol Bonnin [mailto:antonio.fiol@gmail.com]
> > Sent: Thursday, September 23, 2004 8:48 PM
> > To: Jakarta Commons Users List
> > Subject: [configuration] How to load from a resource (as opposed to a
> > file)
> >
> >
> > Hi,
> >
> > <configuration>
> >    <hierarchicalDom4j fileName="someFile.xml" />
> > </configuration>
> >
> > looks for someFile.xml in the same place as the containing xml. Looks
> > good... unless the containing XML is a resource.
> >
> > Possibly due to a bug on ClassLoader implementation in both Tomcat and
> > IBM WAS, if the containing file is in a jar file in WEB-INF/lib, and
> > someFile.xml is in the same package (to make it simpler) in
> > WEB-INF/classes/package/name, the file is not properly loaded, for
> > different reasons in each App server.
> >
> > So the question is: Can I state something like...
> > filename="resource:package/name/someFile.xml" that would ultimately
> > resolve to the right file in the right place?
> >
> > Do I have an alternative other than translating the XML into code that
> > creates the right Configuration objects (in a CompositeConfiguration),
> > but giving each the right URL I got from Class.getResource(String) ?
> >
> > Thank you very much.
> >
> >
> > Antonio Fiol
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [configuration] How to load from a resource (as opposed to a file)

Posted by Eric Pugh <ep...@upstate.com>.
Hi..

I think, and Emmanuel, can you verify for me, that we need to change the
ConfigurationFactory to use the new file locating stuff?  Right now I think
the problem is that in ConfigurationFactory.FileConfigurationFactory, the
logic for finding a file sucks..  I think the whole basePath is wrong..

Antonio, if you could send in a unit test demonstrating this, that would
really help verify that any changes we make solve your problem.

Eric

> -----Original Message-----
> From: Antonio Fiol Bonnin [mailto:antonio.fiol@gmail.com]
> Sent: Thursday, September 23, 2004 8:48 PM
> To: Jakarta Commons Users List
> Subject: [configuration] How to load from a resource (as opposed to a
> file)
>
>
> Hi,
>
> <configuration>
>    <hierarchicalDom4j fileName="someFile.xml" />
> </configuration>
>
> looks for someFile.xml in the same place as the containing xml. Looks
> good... unless the containing XML is a resource.
>
> Possibly due to a bug on ClassLoader implementation in both Tomcat and
> IBM WAS, if the containing file is in a jar file in WEB-INF/lib, and
> someFile.xml is in the same package (to make it simpler) in
> WEB-INF/classes/package/name, the file is not properly loaded, for
> different reasons in each App server.
>
> So the question is: Can I state something like...
> filename="resource:package/name/someFile.xml" that would ultimately
> resolve to the right file in the right place?
>
> Do I have an alternative other than translating the XML into code that
> creates the right Configuration objects (in a CompositeConfiguration),
> but giving each the right URL I got from Class.getResource(String) ?
>
> Thank you very much.
>
>
> Antonio Fiol
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org