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:56:13 GMT

That solved it.  Thank you.


djencks wrote:
> 
> You app is not loaded in the system classloader in geronimo, and  
> almost certainly not in any other app server or non-trivial framework  
> either.
> 
> You should be using
> getClass().getClassLoader().getResourceAsStream()
> 
> or
> 
> MyClass.class.getClassLoader().getResourceAsStream().
> 
> hope this helps
> david jencks
> 
> On Mar 30, 2008, at 9:52 AM, Cedric Hurst 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
>> -- 
>> 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--tp16384195s134p16384965.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message