You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by Nishanth S <ch...@gmail.com> on 2015/07/16 20:49:29 UTC

Properties file not loaded with hadoop jar command

Hello,
I have built a  jar file with maven as build tool which  reads properties
from a  file.I am doing this  like  InputStream is =
ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
iup.No qonce the jar is built  I could see that the properties get loaded
when  I do java -jar but when I am trying to execute the map reduce with
 hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
null.I want to keep this property file  within the jar and is available  in
the classpath.Please  advise  if any one has met this scenario before.


-Chinchu

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Nishanth S <ch...@gmail.com>.
Thanks.Yep its a  java issue.using Thread.contextclassloader would solve
this.

-Nishanth

On Fri, Jul 17, 2015 at 8:17 AM, Shahab Yunus <sh...@gmail.com>
wrote:

> This seems to be a Java issue rather than Hadoop?
>
> Have you seen these below, regarding intricacies involved in reading a
> resource file in Java jar?
>
> http://javarevisited.blogspot.com/2014/07/how-to-load-resources-from-classpath-in-java-example.html
>
> http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
>
> http://stackoverflow.com/questions/403256/how-do-i-read-a-resource-file-from-a-java-jar-file?rq=1
>
> Regards,
> Shahab
>
> On Fri, Jul 17, 2015 at 10:09 AM, Harshit Mathur <ma...@gmail.com>
> wrote:
>
>> Are you reading the file in map or reduce task?
>> On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:
>>
>>> Hello,
>>> I have built a  jar file with maven as build tool which  reads
>>> properties from a  file.I am doing this  like  InputStream is =
>>> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
>>> iup.No qonce the jar is built  I could see that the properties get loaded
>>> when  I do java -jar but when I am trying to execute the map reduce with
>>>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
>>> null.I want to keep this property file  within the jar and is available  in
>>> the classpath.Please  advise  if any one has met this scenario before.
>>>
>>>
>>> -Chinchu
>>>
>>>
>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Nishanth S <ch...@gmail.com>.
Thanks.Yep its a  java issue.using Thread.contextclassloader would solve
this.

-Nishanth

On Fri, Jul 17, 2015 at 8:17 AM, Shahab Yunus <sh...@gmail.com>
wrote:

> This seems to be a Java issue rather than Hadoop?
>
> Have you seen these below, regarding intricacies involved in reading a
> resource file in Java jar?
>
> http://javarevisited.blogspot.com/2014/07/how-to-load-resources-from-classpath-in-java-example.html
>
> http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
>
> http://stackoverflow.com/questions/403256/how-do-i-read-a-resource-file-from-a-java-jar-file?rq=1
>
> Regards,
> Shahab
>
> On Fri, Jul 17, 2015 at 10:09 AM, Harshit Mathur <ma...@gmail.com>
> wrote:
>
>> Are you reading the file in map or reduce task?
>> On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:
>>
>>> Hello,
>>> I have built a  jar file with maven as build tool which  reads
>>> properties from a  file.I am doing this  like  InputStream is =
>>> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
>>> iup.No qonce the jar is built  I could see that the properties get loaded
>>> when  I do java -jar but when I am trying to execute the map reduce with
>>>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
>>> null.I want to keep this property file  within the jar and is available  in
>>> the classpath.Please  advise  if any one has met this scenario before.
>>>
>>>
>>> -Chinchu
>>>
>>>
>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Nishanth S <ch...@gmail.com>.
Thanks.Yep its a  java issue.using Thread.contextclassloader would solve
this.

-Nishanth

On Fri, Jul 17, 2015 at 8:17 AM, Shahab Yunus <sh...@gmail.com>
wrote:

> This seems to be a Java issue rather than Hadoop?
>
> Have you seen these below, regarding intricacies involved in reading a
> resource file in Java jar?
>
> http://javarevisited.blogspot.com/2014/07/how-to-load-resources-from-classpath-in-java-example.html
>
> http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
>
> http://stackoverflow.com/questions/403256/how-do-i-read-a-resource-file-from-a-java-jar-file?rq=1
>
> Regards,
> Shahab
>
> On Fri, Jul 17, 2015 at 10:09 AM, Harshit Mathur <ma...@gmail.com>
> wrote:
>
>> Are you reading the file in map or reduce task?
>> On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:
>>
>>> Hello,
>>> I have built a  jar file with maven as build tool which  reads
>>> properties from a  file.I am doing this  like  InputStream is =
>>> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
>>> iup.No qonce the jar is built  I could see that the properties get loaded
>>> when  I do java -jar but when I am trying to execute the map reduce with
>>>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
>>> null.I want to keep this property file  within the jar and is available  in
>>> the classpath.Please  advise  if any one has met this scenario before.
>>>
>>>
>>> -Chinchu
>>>
>>>
>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Nishanth S <ch...@gmail.com>.
Thanks.Yep its a  java issue.using Thread.contextclassloader would solve
this.

-Nishanth

On Fri, Jul 17, 2015 at 8:17 AM, Shahab Yunus <sh...@gmail.com>
wrote:

> This seems to be a Java issue rather than Hadoop?
>
> Have you seen these below, regarding intricacies involved in reading a
> resource file in Java jar?
>
> http://javarevisited.blogspot.com/2014/07/how-to-load-resources-from-classpath-in-java-example.html
>
> http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
>
> http://stackoverflow.com/questions/403256/how-do-i-read-a-resource-file-from-a-java-jar-file?rq=1
>
> Regards,
> Shahab
>
> On Fri, Jul 17, 2015 at 10:09 AM, Harshit Mathur <ma...@gmail.com>
> wrote:
>
>> Are you reading the file in map or reduce task?
>> On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:
>>
>>> Hello,
>>> I have built a  jar file with maven as build tool which  reads
>>> properties from a  file.I am doing this  like  InputStream is =
>>> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
>>> iup.No qonce the jar is built  I could see that the properties get loaded
>>> when  I do java -jar but when I am trying to execute the map reduce with
>>>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
>>> null.I want to keep this property file  within the jar and is available  in
>>> the classpath.Please  advise  if any one has met this scenario before.
>>>
>>>
>>> -Chinchu
>>>
>>>
>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Shahab Yunus <sh...@gmail.com>.
This seems to be a Java issue rather than Hadoop?

Have you seen these below, regarding intricacies involved in reading a
resource file in Java jar?
http://javarevisited.blogspot.com/2014/07/how-to-load-resources-from-classpath-in-java-example.html
http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
http://stackoverflow.com/questions/403256/how-do-i-read-a-resource-file-from-a-java-jar-file?rq=1

Regards,
Shahab

On Fri, Jul 17, 2015 at 10:09 AM, Harshit Mathur <ma...@gmail.com>
wrote:

> Are you reading the file in map or reduce task?
> On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:
>
>> Hello,
>> I have built a  jar file with maven as build tool which  reads properties
>> from a  file.I am doing this  like  InputStream is =
>> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
>> iup.No qonce the jar is built  I could see that the properties get loaded
>> when  I do java -jar but when I am trying to execute the map reduce with
>>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
>> null.I want to keep this property file  within the jar and is available  in
>> the classpath.Please  advise  if any one has met this scenario before.
>>
>>
>> -Chinchu
>>
>>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Shahab Yunus <sh...@gmail.com>.
This seems to be a Java issue rather than Hadoop?

Have you seen these below, regarding intricacies involved in reading a
resource file in Java jar?
http://javarevisited.blogspot.com/2014/07/how-to-load-resources-from-classpath-in-java-example.html
http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
http://stackoverflow.com/questions/403256/how-do-i-read-a-resource-file-from-a-java-jar-file?rq=1

Regards,
Shahab

On Fri, Jul 17, 2015 at 10:09 AM, Harshit Mathur <ma...@gmail.com>
wrote:

> Are you reading the file in map or reduce task?
> On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:
>
>> Hello,
>> I have built a  jar file with maven as build tool which  reads properties
>> from a  file.I am doing this  like  InputStream is =
>> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
>> iup.No qonce the jar is built  I could see that the properties get loaded
>> when  I do java -jar but when I am trying to execute the map reduce with
>>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
>> null.I want to keep this property file  within the jar and is available  in
>> the classpath.Please  advise  if any one has met this scenario before.
>>
>>
>> -Chinchu
>>
>>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Shahab Yunus <sh...@gmail.com>.
This seems to be a Java issue rather than Hadoop?

Have you seen these below, regarding intricacies involved in reading a
resource file in Java jar?
http://javarevisited.blogspot.com/2014/07/how-to-load-resources-from-classpath-in-java-example.html
http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
http://stackoverflow.com/questions/403256/how-do-i-read-a-resource-file-from-a-java-jar-file?rq=1

Regards,
Shahab

On Fri, Jul 17, 2015 at 10:09 AM, Harshit Mathur <ma...@gmail.com>
wrote:

> Are you reading the file in map or reduce task?
> On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:
>
>> Hello,
>> I have built a  jar file with maven as build tool which  reads properties
>> from a  file.I am doing this  like  InputStream is =
>> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
>> iup.No qonce the jar is built  I could see that the properties get loaded
>> when  I do java -jar but when I am trying to execute the map reduce with
>>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
>> null.I want to keep this property file  within the jar and is available  in
>> the classpath.Please  advise  if any one has met this scenario before.
>>
>>
>> -Chinchu
>>
>>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Shahab Yunus <sh...@gmail.com>.
This seems to be a Java issue rather than Hadoop?

Have you seen these below, regarding intricacies involved in reading a
resource file in Java jar?
http://javarevisited.blogspot.com/2014/07/how-to-load-resources-from-classpath-in-java-example.html
http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
http://stackoverflow.com/questions/403256/how-do-i-read-a-resource-file-from-a-java-jar-file?rq=1

Regards,
Shahab

On Fri, Jul 17, 2015 at 10:09 AM, Harshit Mathur <ma...@gmail.com>
wrote:

> Are you reading the file in map or reduce task?
> On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:
>
>> Hello,
>> I have built a  jar file with maven as build tool which  reads properties
>> from a  file.I am doing this  like  InputStream is =
>> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
>> iup.No qonce the jar is built  I could see that the properties get loaded
>> when  I do java -jar but when I am trying to execute the map reduce with
>>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
>> null.I want to keep this property file  within the jar and is available  in
>> the classpath.Please  advise  if any one has met this scenario before.
>>
>>
>> -Chinchu
>>
>>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Harshit Mathur <ma...@gmail.com>.
Are you reading the file in map or reduce task?
On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:

> Hello,
> I have built a  jar file with maven as build tool which  reads properties
> from a  file.I am doing this  like  InputStream is =
> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
> iup.No qonce the jar is built  I could see that the properties get loaded
> when  I do java -jar but when I am trying to execute the map reduce with
>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
> null.I want to keep this property file  within the jar and is available  in
> the classpath.Please  advise  if any one has met this scenario before.
>
>
> -Chinchu
>
>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Harshit Mathur <ma...@gmail.com>.
Are you reading the file in map or reduce task?
On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:

> Hello,
> I have built a  jar file with maven as build tool which  reads properties
> from a  file.I am doing this  like  InputStream is =
> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
> iup.No qonce the jar is built  I could see that the properties get loaded
> when  I do java -jar but when I am trying to execute the map reduce with
>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
> null.I want to keep this property file  within the jar and is available  in
> the classpath.Please  advise  if any one has met this scenario before.
>
>
> -Chinchu
>
>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Harshit Mathur <ma...@gmail.com>.
Are you reading the file in map or reduce task?
On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:

> Hello,
> I have built a  jar file with maven as build tool which  reads properties
> from a  file.I am doing this  like  InputStream is =
> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
> iup.No qonce the jar is built  I could see that the properties get loaded
> when  I do java -jar but when I am trying to execute the map reduce with
>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
> null.I want to keep this property file  within the jar and is available  in
> the classpath.Please  advise  if any one has met this scenario before.
>
>
> -Chinchu
>
>

Re: Fwd: Properties file not loaded with hadoop jar command

Posted by Harshit Mathur <ma...@gmail.com>.
Are you reading the file in map or reduce task?
On Jul 17, 2015 2:51 AM, "Nishanth S" <ch...@gmail.com> wrote:

> Hello,
> I have built a  jar file with maven as build tool which  reads properties
> from a  file.I am doing this  like  InputStream is =
> ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
> iup.No qonce the jar is built  I could see that the properties get loaded
> when  I do java -jar but when I am trying to execute the map reduce with
>  hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
> null.I want to keep this property file  within the jar and is available  in
> the classpath.Please  advise  if any one has met this scenario before.
>
>
> -Chinchu
>
>

Fwd: Properties file not loaded with hadoop jar command

Posted by Nishanth S <ch...@gmail.com>.
Hello,
I have built a  jar file with maven as build tool which  reads properties
from a  file.I am doing this  like  InputStream is =
ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
iup.No qonce the jar is built  I could see that the properties get loaded
when  I do java -jar but when I am trying to execute the map reduce with
 hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
null.I want to keep this property file  within the jar and is available  in
the classpath.Please  advise  if any one has met this scenario before.


-Chinchu

Fwd: Properties file not loaded with hadoop jar command

Posted by Nishanth S <ch...@gmail.com>.
Hello,
I have built a  jar file with maven as build tool which  reads properties
from a  file.I am doing this  like  InputStream is =
ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
iup.No qonce the jar is built  I could see that the properties get loaded
when  I do java -jar but when I am trying to execute the map reduce with
 hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
null.I want to keep this property file  within the jar and is available  in
the classpath.Please  advise  if any one has met this scenario before.


-Chinchu

Fwd: Properties file not loaded with hadoop jar command

Posted by Nishanth S <ch...@gmail.com>.
Hello,
I have built a  jar file with maven as build tool which  reads properties
from a  file.I am doing this  like  InputStream is =
ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
iup.No qonce the jar is built  I could see that the properties get loaded
when  I do java -jar but when I am trying to execute the map reduce with
 hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
null.I want to keep this property file  within the jar and is available  in
the classpath.Please  advise  if any one has met this scenario before.


-Chinchu

Fwd: Properties file not loaded with hadoop jar command

Posted by Nishanth S <ch...@gmail.com>.
Hello,
I have built a  jar file with maven as build tool which  reads properties
from a  file.I am doing this  like  InputStream is =
ClassLoader.getSystemResourceAsStream(("hadoop.properties")) on start
iup.No qonce the jar is built  I could see that the properties get loaded
when  I do java -jar but when I am trying to execute the map reduce with
 hadoop jar  ClassLoader.getSystemResourceAsStream returns input stream
null.I want to keep this property file  within the jar and is available  in
the classpath.Please  advise  if any one has met this scenario before.


-Chinchu