Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oozie Java Action : Passing Hbase classpath

I'm running a test hbase java program via oozie java action. The following error is encountered :

Failing Oozie Launcher, Main class [HbaseTest], main() threw exception, org/apache/hadoop/hbase/HBaseConfiguration
java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration
at HbaseTest.main(HbaseTest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.oozie.action.hadoop.LauncherMapper.map(LauncherMapper.java:495)
at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:50)
at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:417)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:332)
at org.apache.hadoop.mapred.Child$4.run(Child.java:268)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1438)
at org.apache.hadoop.mapred.Child.main(Child.java:262)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.HBaseConfiguration
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 14 more

The program runs correctly from command line :

java -cp `hbase classpath`  HbaseTest

Is there a way I can pass output of 'hbase classpath' to the oozie java action. I dont want to copy hbase jars to workflow's lib directory as that will be a maintenance overhead.

Following is the java action from workflow.xml :

    <java>
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <configuration>
            <property>
                <name>mapred.job.queue.name</name>
                <value>${queueName}</value>
            </property>
        </configuration>
        <main-class>HbaseTest</main-class>
        <java-opts></java-opts>
        <arg>HELLO</arg>
    </java>
like image 379
NZ. Avatar asked Oct 01 '14 02:10

NZ.


1 Answers

Since Oozie 2.3 you can use Share Libraries:

Oozie supports job and system share libraries for workflow jobs.

Share libraries can simplify the deployment and management of common components across workflow applications.

For example, if a workflow job uses a share library with the Streaming, Pig & Har JARs files it does not have to bundled those JARs files in the workflow application lib/ path.

If workflow job uses a share library, Oozie will include all the JAR/SO files in the library in the classpath/libpath for all its actions.

A workflow job can specify a share library path using the job property oozie.libpath .

A workflow job can use the system share library by setting the job property oozie.use.system.libpath to true .

http://oozie.apache.org/docs/3.2.0-incubating/WorkflowFunctionalSpec.html#a17_HDFS_Share_Libraries_for_Workflow_Applications_since_Oozie_2.3

How to install: http://oozie.apache.org/docs/4.0.0/DG_QuickStart.html#OozieShareLib

like image 53
pedromrnd Avatar answered Oct 19 '22 21:10

pedromrnd