Well, what do I say? I put a file resource.txt into my rar's META-INF
directory and another application.xml into my ear's META-INF directory. Then
I wrote a small test class that tries to load both files via
(1) getClass().getClassLoader().getResourceAsStream("META-INF/resource.txt")
and
(2)
getClass().getClassLoader().getResourceAsStream("META-INF/application.xml"),
placing it inside my rar (which subsequently gets bundled in my ear), taking
care to execute it on startup. Oh yes, and I tried both with a leading /,
too.
While (1) returns null, (2) works like a charm. Do we have a problem now, or
am I missing something?
Cheers,
Olaf
djencks wrote:
>
>
> On Mar 13, 2009, at 6:55 AM, Olaf Bergner wrote:
>
>>
>> I have an application packaged as an ear containing wars, rars and
>> ejb-jars.
>> Employing what little I have in the way of graphical talent I would
>> visualize the overall structure as
>>
>> app-ear - META-INF/application.xml
>> |
>> ------- ra.rar - META-INF/ra.xml
>> | - META-INF/resource.xml
>> |
>> (further JEE modules)
>>
>> From inside code deployed in ra.rar I'm trying to access the classpath
>> resource
>>
>> ra.rar/META-INF/resource.xml
>>
>> using the usual getResourceAsStream(...) mechanism.
>>
>> This however fails, i.e. returns null. Only if I put resource.xml
>> inside the
>> ear's META-INF directory am I able to access it.
>
> Stuff in the rar such as your ra.rar/META-INF/resource.xml would be
> accessible at META-INF/resource.xml, not ra.rar/META-INF/resource.xml
> (you might need /META-INF/resource.xml) If this doesn't work we have
> a problem (I think :-)
>
> thanks
> david jencks
>
>>
>>
>> My expectation is that this is such a common requirement and that when
>> accessing resources from inside a JEE module you naturally expect
>> those
>> resources to be resolved relative to the current module and not
>> relative to
>> the enclosing ear so that there has to be some standard solution. Am I
>> wrong?
>>
>> Thx,
>> Olaf
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Access-resources-in-rar-embedded-inside-an-ear-tp22496887s134p22496887.html
>> Sent from the Apache Geronimo - Users mailing list archive at
>> Nabble.com.
>>
>
>
>
--
View this message in context:
http://www.nabble.com/Access-resources-in-rar-embedded-inside-an-ear-tp22496887s134p22504071.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.