The reason this is happening is that the way getResource works. It essentially delegates the call to the classLoader of the classname as put it in your question.
The reason this is happening is that the way getResource works. It essentially delegates the call to the classLoader of the as put it in your question. The Class object was probably loaded by the bootstrap classloader in an enterprise application whereas your class was loaded by a different classloader.
Ah I see. Is there anything that I can log to verify this. Or is there something I can look for in the source?
– smartnut007 Jul 25 at 23:42 Could you explain a little more as to how this could affect the availability of resources in the classpath. – smartnut007 Jul 25 at 23:54 @smartnut007 -- sorry for the late response. You can refer to the ClassLoader api .. what will help is to print the URL of the classloader.
GetResource(yourclass) to help isolate your problem. – Kal Jul 26 at 1:06.
Class.getResource() resolves relative paths by appending it to the path of the class on which you called getResource(). A path is relative unless it begins with a "/", in which case it's resolved against the root of the classpath. ClassLoader.getResource() resolves all paths as absolute, but you mustn't prepend a "/" to the path.
That's all there is to it, really. If either method returns null, it means the resource doesn't exist. Edit: Oh, I'm sorry.
I didn't read your question carefully enough and missed the Class vs. class part. The distinction you're looking for is that loading a resource via a class delegates to its associated ClassLoader. I don't know much about how Hadoop sets up its ClassLoaders, but the java.lang.
Class class will have been loaded by the bootstrap ClassLoader, and almost certainly, the bootstrap ClassLoader doesn't have any of your jars on its classpath, so it would fail to find any resources defined therein. Your own class, however, would have to be loaded by a ClassLoader that has access to your jars, and thus would be able to load your resource.
I know that. If you notice carefully , there is really no ClassLoader here. – smartnut007 Jul 25 at 23:37 @smartnut: There's always a ClassLoader.
Updated my answer. – Ryan Stewart Jul 26 at 1:18.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.