Execute MAPRDEUC program error under Eclipse java.lang.ClassNotFoundException

Source: Internet
Author: User

Recently encountered a problem, I do not know how suddenly run Hadoop Map program error, bothered me for a long time, now to share with you.

error Message

2017-05-18 21:34:22,104 INFO [main] client. Rmproxy (RMProxy.java:createRMProxy)-Connecting to ResourceManager at/0.0.0.0:8032 2017-05-18 21:34:22,642 WARN [m Ain] MapReduce. Jobresourceuploader (JobResourceUploader.java:uploadFiles)-Hadoop command-line option parsing not performed.
Implement the Tool interface and execute your application with Toolrunner to remedy this. 2017-05-18 21:34:22,689 WARN [main] MapReduce.  Jobresourceuploader (JobResourceUploader.java:uploadFiles (171))-No job jar file set. User classes May is found.
The Job#setjar (String). 2017-05-18 21:34:22,748 INFO [main] input. Fileinputformat (FileInputFormat.java:listStatus (283))-Total input paths to process:1 2017-05-18 21:34:23,064 INFO [m Ain] MapReduce. Jobsubmitter (JobSubmitter.java:submitJobInternal (198))-Number of Splits:3 2017-05-18 21:34:23,263 INFO [main] mapredu Ce. Jobsubmitter (JobSubmitter.java:printTokens (287))-Submitting tokens for job:job_1495112477030_0010 2017-05-1821:34:23,521 INFO [main] mapred. Yarnrunner (YARNRunner.java:createApplicationSubmissionContext (371))-Job jar is not present.
Not adding any jars to the list of resources. 2017-05-18 21:34:23,598 INFO [main] impl.
Yarnclientimpl (YarnClientImpl.java:submitApplication (273))-Submitted application application_1495112477030_0010 2017-05-18 21:34:23,661 INFO [main] MapReduce.
Job (Job.java:submit (1294))-the URL to track the job:http://ubuntu-zj0633:8088/proxy/application_1495112477030_0010/ 2017-05-18 21:34:23,662 INFO [main] MapReduce. Job (Job.java:monitorAndPrintJob (1339))-Running job:job_1495112477030_0010 2017-05-18 21:34:30,858 INFO [main] mapred Uce. Job (Job.java:monitorAndPrintJob (1360))-Job job_1495112477030_0010 running in Uber mode:false 2017-05-18 21:34:30,859 INFO [main] MapReduce. Job (Job.java:monitorAndPrintJob (1367))-map 0% reduce 0% 2017-05-18 21:34:39,078 INFO [main] MapReduce. Job (Job.java:monitorAndPrintJob (1367))-map 33% reduce 0% 2017-05-18 21:34:39,087 INFO [main] MapReduce. Job (Job.java:printTaskEvents (1406))-Task Id:attempt_1495112477030_0010_m_000000_0, status:failed Error:java.lang. RuntimeException:java.lang.ClassNotFoundException:Class Com.map.count.TokenizerMapper not found at Org.apache.hadoop.conf.Configuration.getClass (configuration.java:2195) at Org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass (jobcontextimpl.java:186) at Org.apache.hadoop.mapred.MapTask.runNewMapper (maptask.java:745) at Org.apache.hadoop.mapred.MapTask.run ( maptask.java:341) at Org.apache.hadoop.mapred.yarnchild$2.run (yarnchild.java:164) at
	Java.security.AccessController.doPrivileged (Native method) at Javax.security.auth.Subject.doAs (subject.java:422) At Org.apache.hadoop.security.UserGroupInformation.doAs (usergroupinformation.java:1698) at Org.apache.hadoop.mapred.YarnChild.main (yarnchild.java:158) caused By:java.lang.ClassNotFoundException:Class Com.map.count.TokenizerMapper not found at org.apache.hadoop.conf.ConfIguration.getclassbyname (configuration.java:2101) at Org.apache.hadoop.conf.Configuration.getClass ( configuration.java:2193) ... 8 more


Solutions

Mode one:

The online general method does not work at all, see a Netizen the following method:

First or foremost, make sure that you follow a common approach:

Add Job.setjarbyclass (Wordcount.class) to main; (The general version has this, the following will know, this is the problem, in fact, basically useless).

Mode two:

1, package the item into a. Jar at the end of the jar package in a specified directory.

2, add Job.setjar (jar path) to the job submission in the project; Where the jar path is the absolute path of the file you just exported, such as/home/hadoop/workspace/wordcount.jar

3, run again, error avoidance

Mode three:

1, delete the project directory, such as core-site.xml,mapred-site.xml configuration information, do not submit to the cluster bench to run.

2, the input and output path in the project, plus the URL of the hdfs://master node

3, run again, problem solved.


The explanation for this problem

Warning in the question

2017-05-18 21:34:22,689 WARN  [main] MapReduce. Jobresourceuploader (JobResourceUploader.java:uploadFiles (171))-No job Jar file set.  User classes May is found. Job#setjar (String)

This statement sets the job Jar package unsuccessful. This is why.

Because this method uses the Wordcount.class ClassLoader to find the jar package that contains the class, and then set the jar package for the job. But our job jar package is packaged while the program is running, and the Wordcount.class ClassLoader is Appclassloader, and we cannot change its search path after running, so using Setjarbyclass is unable to set the job jar package. We have to use the Setjar in jobconf to set up the job jar package directly, as follows:

((jobconf) job.getconfiguration ()). Setjar (Jarfile); (The jarfile variable of this method is not clear about what should be, mainly for the functionality of the Setjar, this method is not discussed here, The solution is to use the original) so the reason is clear, job.setjarbyclass (Wordcoun.class) to set the path of the jar package and make it the job jar package, but the program does not generate a jar package when it is run, but it does not exist at this time, so it fails. Our initial approach is to manually generate the jar package and then specify the path. So it's not necessary. And the direct execution of WordCount under Linux why is it possible. Because what you're doing is the jar package, which means that the code you use is a jar pack to execute, or that Job.setjarbyclass (Wordcoun.class) is executed in the JAR package environment.


In fact, mode two way is a cluster of operation, need to specify the corresponding jar file, and mode three, is based on the local mode of operation, but the input and output files to the HDFs, the actual running program or in the local.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.