geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cedric Hurst <cedric.hu...@gmail.com>
Subject Re: ClassLoader.getSystemResourceAtStream() within Geronimo utility JAR?
Date Sun, 30 Mar 2008 17:12:14 GMT

Thanks for the prompt reply, Vasmi.  I've tried both adding the jar file as a
module in the app server (and defining the dependency in my
geronimo-web.xml), and I've also tried including the JAR in the WEB-INF\lib
folder of the war file as well.  I've attached a war file which uses the
latter method.  To reproduce the error, try accessing
http://localhost:8080/cityLookup/CityLookupServlet?s=chi

http://www.nabble.com/file/p16384415/cityLookup.war cityLookup.war 


Vamsavardhana Reddy-2 wrote:
> 
> Are you packaging this jar in WEB-INF\lib directory in the war file?
> 
> ++Vamsi
> 
> On Sun, Mar 30, 2008 at 10:22 PM, Cedric Hurst <cedric.hurst@gmail.com>
> wrote:
> 
>>
>> I have a utility JAR which reads from a flat file ("cities.txt") which is
>> contained within the JAR itself.  This file is used to initially populate
>> a
>> collection in memory.  I'm using the
>> ClassLoader.getSystemResourceAsStream
>> ()
>> method to retrieve this flat file as an InputStream within my utility JAR
>> class.  In Java SE, I can add the utility JAR the the classpath of a
>> client
>> and it will find the flat file just fine.  But if I try to deploy this
>> JAR
>> to Geronimo and use it within a web application,
>> ClassLoader.getSystemResourcesAsStream() returns null.  I'm guessing
>> Geronimo is doing some tricky things which involve overriding the system
>> classloader.  Here's the stack trace.
>>
>> java.lang.NullPointerException
>>        at java.io.Reader.<init>(Reader.java:82)
>>        at java.io.InputStreamReader.<init>(InputStreamReader.java:89)
>>        at util.cityLookup.Lookup.init(Lookup.java:21)
>>        at util.cityLookup.Lookup.checkInitilization(Lookup.java:45)
>>        at util.cityLookup.Lookup.citiesBeginningWith(Lookup.java:52)
>>        at web.jsf.CitySuggester.getCityList(CitySuggester.java:10)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
>> :79)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>> DelegatingMethodAccessorImpl.java:43)
>>        at java.lang.reflect.Method.invoke(Method.java:618)
>>        at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
>>        at org.apache.el.MethodExpressionImpl.invoke(
>> MethodExpressionImpl.java:276)
>>        at
>> org.apache.myfaces.el.convert.MethodExpressionToMethodBinding.invoke(
>> MethodExpressionToMethodBinding.java:73)
>>        ... 30 more
>>
>>
>> I've attached the JAR file.  Is there an alternate means of accessing the
>> flat file within my Lookup class (without using absolute paths)?
>>
>> http://www.nabble.com/file/p16384195/cityLookup-1.0-NABBLE.jar
>> cityLookup-1.0-NABBLE.jar<http://www.nabble.com/file/p16384195/cityLookup-1.0-NABBLE.jarcityLookup-1.0-NABBLE.jar>
>> --
>> View this message in context:
>> http://www.nabble.com/ClassLoader.getSystemResourceAtStream%28%29-within-Geronimo-utility-JAR--tp16384195s134p16384195.html
>> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ClassLoader.getSystemResourceAtStream%28%29-within-Geronimo-utility-JAR--tp16384195s134p16384415.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message