我正在尝试运行WordCount程序。我创建了wordcount.jar。 以下是我的罐子的内容。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div id="box">
<h3 class="word" style="margin:10px 30px 30px 30px;">Issue Report</h3>
<div class="word" style="width: 100px; margin-left: auto; margin-right: auto">Type Of Issue:</div>
<div style=" max-width: 150px; margin-left: auto; margin-right: auto; padding: 2px">
<form action="BugReport.php" method="post">
<select class="buttons" name="type1" id="type1" style='max-width: 150px;'>
<?php $servername="localhost" ; $username="user" ; $password="pass" ; $database="db" ; $con=m ysqli_connect($servername,$username,$password,$database); if($con->connect_error){ die("Connection failed " . $con->connect_error); } $sql1 = "select issue_name, issue_description from Issue"; $result = mysqli_query($con,$sql1); while ($row = mysqli_fetch_array($result)) { $issue = $row['issue_name']; $des =
$row['issue_description']; echo "
<option value='$issue' title='$des'>$issue</option>"; } ?>
</select>
</form>
</div>
<form action="BugReport.phpl" method="post">
<div id="Buyers1" style="display:none;">
<select class="buttons receiver" name="Buyers" id="Buyers" style="margin: 0px 30px 0px 30px;">
<?php $sql="select first, last from Employee where department_id = '1'" ; $result=m ysqli_query($con,$sql); while ($row=m ysqli_fetch_array($result)) { $name=$ row[ 'first'] . ' ' . $row[ 'last']; echo "<option value = '$name'>$name</option>"; } ?>
</select>
</div>
</form>
<div id="Operations1" style="display:block;">
<form action="BugReport.php" method="post">
<select class="buttons receiver" name="Operations" id="Operations" style="margin: 0px 30px 0px 30px;">
<?php $sql="select first, last from Employee where department_id = 2" ; $result=m ysqli_query($con,$sql); while ($row=m ysqli_fetch_array($result)) { $name=$ row[ 'first'] . ' ' . $row[ 'last']; echo "<option value = '$name'>$name</option>"; } ?>
</select>
</form>
</div>
<div id="IT1" style="display:none;">
<form action="BugReport.php" method="post">
<select class="buttons receiver" name="IT" id="IT" style="margin: 0px 30px 0px 30px;">
<?php $sql="select first, last from Employee where department_id = 3" ; $result=m ysqli_query($con,$sql); while ($row=m ysqli_fetch_array($result)) { $name=$ row[ 'first'] . ' ' . $row[ 'last']; echo "<option value = '$name'>$name</option>"; } ?>
</select>
</form>
</div>
<div id="CustomerService1" style="display:none;">
<form action="BugReport.html" method="post">
<select class="buttons receiver" name="CustomerService" id="CustomerService" style="margin: 0px 30px 0px 30px;">
<?php $sql="select first, last from Employee where department_id = 4" ; $result=m ysqli_query($con,$sql); while ($row=m ysqli_fetch_array($result)) { $name=$ row[ 'first'] . ' ' . $row[ 'last']; echo "<option value = '$name'>$name</option>"; } ?>
</select>
</form>
</div>
<div id="HR1" style="display:none;">
<form action="BugReport.html" method="post">
<select class="buttons receiver" name="HR" id="HR" style="margin: 0px 30px 0px 30px;">
<?php $sql="select first, last from Employee where department_id = 5" ; $result=m ysqli_query($con,$sql); while ($row=m ysqli_fetch_array($result)) { $name=$ row[ 'first'] . ' ' . $row[ 'last']; echo "<option value = '$name'>$name</option>"; } ?>
</select>
</form>
</div>
<div id="Logistics1" style="display:none;">
<form action="BugReport.html" method="post">
<select class="buttons receiver" name="Logistics" id="Logistics" style="margin: 0px 30px 0px 30px;">
<?php $sql="select first, last from Employee where department_id = 6" ; $result=m ysqli_query($con,$sql); while ($row=m ysqli_fetch_array($result)) { $name=$ row[ 'first'] . ' ' . $row[ 'last']; echo "<option value = '$name'>$name</option>"; } ?>
</select>
</form>
</div>
<form action="BugDisplayAndReply.html" method="post">
<label></label>
<br>
<textarea style="max-width: 156px; background-color: #F3F9FF; border-color: #0000E6;" cols="20" rows="34" name="issue" id="issue" placeholder="Enter Your Issue Here" "></textarea></form><br>
<div class="word " style="width: 50px; margin-left: auto; margin-right: auto ">Priority:</div>
<div style = "width: 70px; margin-left: auto; margin-right: auto; padding: 2px ">
<form action="BugReport.html " method="post ">
<select class = "buttons " name = "priority " id = "priority ">
<option value = "Low ">Low</option>
<option value = "Regular " selected>Regular</option>
<option value = "High ">High</option>
<option value = "Urgent ">Urgent</option>
</select>
</form></div>
<div style = "width: 50px; margin-left: auto; margin-right: auto; padding: 2px ">
<input class = "buttons " type ="submit " name = "sub " value = "Submit " id = "sub "></div>
<div id="result "></div>
</div>
我使用以下命令运行程序:
META-INF/<br>
META-INF/MANIFEST.MF<br>
org/myorg/WordCount.class<br>
org/myorg/WordCount$IntSumReducer.class<br>
org/myorg/WordCount$TokenizerMapper.class<br>
但是我得到了以下错误:
hadoop jar ./wordcount.jar org.myorg. WordCount mreduce/input mreduce/output
但后来我使用了java.lang.RuntimeException: java.lang.ClassNotFoundException: Class org.myorg.WordCount$TokenizerMapper not found
at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1895)
at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:191)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:631)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)
at org.apache.hadoop.mapred.Child$4.run(Child.java:268)
这个问题已经解决了。有人可以解释一下吗?
答案 0 :(得分:0)
这更像是一个配置问题而不是hadoop问题。你的wordcount java代码,需要hadoop jar和mapreduce jar(主要是客户端)。因此,当您运行字数统计jar时,您的代码需要hadoop jar的引用,它们位于HADOOP_CLASSPATH目录中。这就是设置路径后你能够运行的原因。
您的系统应将类路径设置为env变量。
或者,您可以在wordcount jar本身(胖罐)中包含所有必需的jar。