嗨我在脚本中运行java程序时遇到错误,该脚本正在oozie shell action workflow中执行 .
Stdoutput 2015-08-25 03:36:02,636 INFO [pool-1-thread-1] (ProcessExecute.java:68) - Exception in thread "main" java.io.IOException: Error opening job jar: /tmp/jars/first.jar
Stdoutput 2015-08-25 03:36:02,636 INFO [pool-1-thread-1] (ProcessExecute.java:68) - at org.apache.hadoop.util.RunJar.main(RunJar.java:124)
Stdoutput 2015-08-25 03:36:02,636 INFO [pool-1-thread-1] (ProcessExecute.java:68) - Caused by: java.io.FileNotFoundException: /tmp/jars/first.jar (No such file or directory)
Stdoutput 2015-08-25 03:36:02,636 INFO [pool-1-thread-1] (ProcessExecute.java:68) - at java.util.zip.ZipFile.open(Native Method)
Stdoutput 2015-08-25 03:36:02,637 INFO [pool-1-thread-1] (ProcessExecute.java:68) - at java.util.zip.ZipFile.<init>(ZipFile.java:215)
Stdoutput 2015-08-25 03:36:02,637 INFO [pool-1-thread-1] (ProcessExecute.java:68) - at java.util.zip.ZipFile.<init>(ZipFile.java:145)
Stdoutput 2015-08-25 03:36:02,637 INFO [pool-1-thread-1] (ProcessExecute.java:68) - at java.util.jar.JarFile.<init>(JarFile.java:154)
Stdoutput 2015-08-25 03:36:02,637 INFO [pool-1-thread-1] (ProcessExecute.java:68) - at java.util.jar.JarFile.<init>(JarFile.java:91)
Stdoutput 2015-08-25 03:36:02,640 INFO [pool-1-thread-1] (ProcessExecute.java:68) - at org.apache.hadoop.util.RunJar.main(RunJar.java:122)
Exit code of the Shell command 1
以下是文件详细信息:
job.properties:
nameNode=maprfs:///
jobTracker=maprfs:///
queueName=nitin
EXEC=execution.jar
ozie.libpath=${nameNode}/user/oozie/share/lib
oozie.use.system.libpath=true
oozie.wf.application.path=maprfs:/dev/user/oozieTest
workflow.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<workflow-app name="test" xmlns="uri:oozie:workflow:0.4">
<start to="first" />
<action name="first">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>script</exec>
<argument>-type mine</argument>
<argument>-cfg config.cfg</argument>
<file>script</file>
<file>${EXEC}#${EXEC}</file>
<file>config.cfg</file>
<file>first.jar#first.jar</file>
<file>second.jar#second.jar</file>
</shell>
<ok to="end" />
<error to="fail" />
</action>
<kill name="fail">
<message>Workflow failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end" />
</workflow-app>
脚本:
#!/bin/bash
#get the user who executed the script
EXECUTING_USER="user1"
# get start time
NOW=$(date +"%T")
#get the host name
HOST="$HOSTNAME"
ARGUMENTSTRING="$@ -user user1 -startTime $NOW"
echo "Passing the following arguments : $ARGUMENTSTRING"
java -cp execution.jar com.hadoop.test.Main "$ARGUMENTSTRING"
exit $?
我从/ tmp / jars目录中的execution.jar文件中获取first.jar,原因是此目录不会向oozie工作流用户创建任何权限问题 .
任何方向/建议都会非常有帮助 .
我在坚果壳中的问题:
-
我想在oozie shell动作节点中执行脚本 .
-
从oozie shell操作节点执行的脚本将运行java程序
-
基于参数的java程序将运行first.jar或second.jar
1 回答
我建议你以某种方式将shell脚本中的依赖项转换为java代码并使用oozie java action节点运行它,这将简化流程以实现良好的扩展 .
如果从oozie shell动作节点运行Java jar是你的最后一个选择,那么我们将很好地做到这一点,但据我所知,它有点复杂 .
主要关注点是,
任何Oozie动作都不能引用该节点的本地文件系统上的内容,它只能引用HDFS上的内容
Java二进制命令只能引用本地文件系统上的文件 .
因此,请按照以下步骤操作,这可能有助于您协调您的期望 .