Home Forums HBase HBase Java Application

Tagged: 

This topic contains 10 replies, has 4 voices, and was last updated by  tedr 1 year, 9 months ago.

  • Creator
    Topic
  • #12466

    David Choe
    Member

    I am trying to compile and run a HBase Java application with Ant on Amazon EC2 Sandbox.
    Is a tutorial available?

    Thanks
    David

Viewing 10 replies - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

  • Author
    Replies
  • #12492

    tedr
    Member

    Hi David,

    It is real difficult to tell what it means when you run it with ant, not knowing what the ant file contains. It could mean what you expect, or it could mean that it was just successfully compiled. I strongly suggest that you find the script I mentioned earlier and use that to launch it, as that is the only way you can be sure that all of the correct jars are on the classpath and the correct environment variables are set.

    Thanks,
    Ted.

    Collapse
    #12491

    David Choe
    Member

    I ran the app with ant and get

    [java] GET: Some Value
    [java] Found row: keyvalues={myLittleRow/myLittleFamily:someQualifier/1354575201826/Put/vlen=10}

    BUILD SUCCESSFUL
    Total time: 5 seconds

    Does this indicate my app successfully accessed the hbase table?

    Regards,
    David

    Collapse
    #12490

    tedr
    Member

    Hi David,

    Another thing, somewhere in the directory where hbase was built there should a script called hbase-start.sh, which should be used to start hbase. When launched with this script it will properly set the classpath. When you set the classpath as you did earlier, it will have only that jar on the classpath and there are MANY other jars that are needed for HBase to run.

    Thanks,
    Ted.

    Collapse
    #12488

    tedr
    Member

    Hi David,

    The exception could also mean that the jar didn’t get built correctly and the specific class is either missing or in an unexpected place within the jar file.

    Thanks,
    Ted.

    Collapse
    #12487

    David Choe
    Member

    I can run hbase shell to create a hbase table.
    You may be right. I don’t have to add hbase-site.xml to ant build.xml. Instead I added hbase-site.xml to my code as shown in the previous.

    Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.HBaseConfiguration indicates that my app couldn’t find the class even though I defined CLASSPATH in .bash_profile such that

    CLASSPATH=/usr/lib/hbase/hbase-0.92.1.15.jar
    export CLASSPATH

    [root@hortonworks-sandbox dist]# echo $CLASSPATH
    /usr/lib/hbase/hbase-0.92.1.15.jar

    Any suggestions?

    Collapse
    #12486

    tedr
    Member

    Hi David,

    Are you running some tests after you build HBase? If not please explain why you need to integrate hbase-site.xml in an Ant script. If you are trying to run HBase after building it, after installing HBase there is usually a start script in the HBase install directory. Also one thing that is not apparent from your earlier posts, you do have hadoop up and running on the box where you tryim go run HBase right?

    Thanks,

    Ted.

    Collapse
    #12485

    David Choe
    Member

    My hbase app is to write and read data to hbase in hortonworks.
    I added the following to my java code instead of build.xml
    config.addResource(new Path(“/etc/hadoop/conf/core-site.xml”));
    config.addResource(new Path(“/etc/hadoop/conf/hdfs-site.xml”));
    config.addResource(new Path(“/etc/hbase/conf/hbase-site.xml”));

    Still I have the following errors:

    [root@hortonworks-sandbox dist]# java -jar H*.jar
    Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration
    at HBaseConnector.main(Unknown Source)
    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)
    … 1 more

    Collapse
    #12484

    Sasha J
    Moderator

    David,
    could you please be more specific?
    What is your app configuration related code and what it your ant build.xml have in it?

    Thank you!
    Sasha

    Collapse
    #12483

    David Choe
    Member

    I have more specific question.
    I can build an hbase app using ant build.xml, but I got run-time error. I think it is because path was not defined in my app.
    Can you explain how to integrate Hortonwork hbase-site.xml with Ant build.xml ?

    Regards,
    David

    Collapse
    #12468

    Seth Lyubich
    Keymaster

    Hi David,

    Thank you for using HDP.

    I don’t think we have specific tutorial available. I will check further and will let you know if I find anything.

    Regards,
    Seth

    Collapse
Viewing 10 replies - 1 through 10 (of 10 total)