phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashutosh Sharma <ashu.sharma.in...@gmail.com>
Subject Problems getting started with Apache Phoenix
Date Sat, 19 Sep 2015 14:59:46 GMT
Hi,
I am very new to HBase as well as Apache Phoenix.
Tried making use of this basic program to do the connectivity check etc...
import java.sql.*;
import java.util.*;

public class phoenixTest
{
public static void main(String args[]) throws Exception
{
Connection conn;
Properties prop = new Properties();
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
//conn =
DriverManager.getConnection("jdbc:phoenix:localhost:/hbase-unsecure");
//conn =
DriverManager.getConnection("jdbc:phoenix:localhost:2181/hbase-unsecure");
conn = DriverManager.getConnection("jdbc:phoenix:localhost");
System.out.println("got connection");
ResultSet rst = conn.createStatement().executeQuery(
"select * from stock_symbol");
while (rst.next())
{
System.out.println(rst.getString(1) + " " + rst.getString(2));
}
System.out.println(conn.createStatement().executeUpdate(
"delete from stock_symbol"));
conn.commit();
rst = conn.createStatement().executeQuery("select * from stock_symbol");
while (rst.next())
{
System.out.println(rst.getString(1) + " " + rst.getString(2));
}
System.out
.println(conn
.createStatement()
.executeUpdate(
"upsert into stock_symbol values('IBM','International Business
Machines')"));
conn.commit();
}
}

But getting this issue:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in
[jar:file:/hbase-1.1.2/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/home/ashu/Downloads/phoenix-4.5.2-HBase-1.1-bin/phoenix-4.5.2-HBase-1.1-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Driver class loaded successfully
15/09/19 07:54:01 INFO zookeeper.RecoverableZooKeeper: Process
identifier=hconnection-0x43738a82 connecting to ZooKeeper
ensemble=localhost:2181
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client environment:host.name
=ashu-700-430qe
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:java.version=1.8.0_25
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:java.vendor=Oracle Corporation
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:java.home=/jdk1.8.0_25/jre
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:java.class.path=/root/workspace_hbase/HBaseIntro/bin:/hbase-1.1.2/lib/hbase-client-1.1.2.jar:/hbase-1.1.2/lib/hbase-common-1.1.2.jar:/hbase-1.1.2/lib/zookeeper-3.4.6.jar:/usr/local/hadoop/hadoop-core-1.2.1.jar:/usr/local/hadoop/lib/commons-configuration-1.6.jar:/hbase-1.1.2/lib/commons-logging-1.2.jar:/hbase-1.1.2/lib/commons-lang-2.6.jar:/hbase-1.1.2/lib/protobuf-java-2.5.0.jar:/hbase-1.1.2/lib/hbase-protocol-1.1.2.jar:/hbase-1.1.2/lib/slf4j-log4j12-1.7.5.jar:/hbase-1.1.2/lib/slf4j-api-1.7.7.jar:/hbase-1.1.2/lib/log4j-1.2.17.jar:/hbase-1.1.2/lib/htrace-core-3.1.0-incubating.jar:/hbase-1.1.2/lib/guava-12.0.1.jar:/hbase-1.1.2/lib/guice-3.0.jar:/hbase-1.1.2/lib/netty-all-4.0.23.Final.jar:/hbase-1.1.2/lib/netty-3.2.4.Final.jar:/home/ashu/Downloads/phoenix-4.5.2-HBase-1.1-bin/phoenix-core-4.5.2-HBase-1.1.jar:/home/ashu/Downloads/phoenix-4.5.2-HBase-1.1-bin/phoenix-flume-4.5.2-HBase-1.1.jar:/home/ashu/Downloads/phoenix-4.5.2-HBase-1.1-bin/phoenix-pig-4.5.2-HBase-1.1.jar:/home/ashu/Downloads/phoenix-4.5.2-HBase-1.1-bin/phoenix-spark-4.5.2-HBase-1.1.jar:/home/ashu/Downloads/phoenix-4.5.2-HBase-1.1-bin/phoenix-server-4.5.2-HBase-1.1.jar:/home/ashu/Downloads/phoenix-4.5.2-HBase-1.1-bin/phoenix-server-client-4.5.2-HBase-1.1.jar:/home/ashu/Downloads/phoenix-4.5.2-HBase-1.1-bin/phoenix-4.5.2-HBase-1.1-client.jar
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:java.io.tmpdir=/tmp
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:java.compiler=<NA>
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:os.version=3.13.0-63-generic
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client environment:user.name
=root
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:user.home=/root
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Client
environment:user.dir=/root/workspace_hbase/HBaseIntro
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Initiating client connection,
connectString=localhost:2181 sessionTimeout=90000
watcher=hconnection-0x43738a820x0, quorum=localhost:2181, baseZNode=/hbase
15/09/19 07:54:01 INFO zookeeper.ClientCnxn: Opening socket connection to
server localhost/127.0.0.1:2181. Will not attempt to authenticate using
SASL (unknown error)
15/09/19 07:54:01 INFO zookeeper.ClientCnxn: Socket connection established
to localhost/127.0.0.1:2181, initiating session
15/09/19 07:54:01 INFO zookeeper.ClientCnxn: Session establishment complete
on server localhost/127.0.0.1:2181, sessionid = 0x14fe3b6b1e40039,
negotiated timeout = 40000
15/09/19 07:54:01 INFO client.ConnectionManager$HConnectionImplementation:
Closing zookeeper sessionid=0x14fe3b6b1e40039
15/09/19 07:54:01 INFO zookeeper.ZooKeeper: Session: 0x14fe3b6b1e40039
closed
15/09/19 07:54:01 INFO zookeeper.ClientCnxn: EventThread shut down
Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.instance()Lorg/apache/hadoop/metrics2/MetricsSystem;
at org.apache.phoenix.metrics.Metrics.<clinit>(Metrics.java:29)
at
org.apache.phoenix.trace.TraceMetricSource.<init>(TraceMetricSource.java:86)
at
org.apache.phoenix.trace.util.Tracing.addTraceMetricsSource(Tracing.java:269)
at
org.apache.phoenix.jdbc.PhoenixConnection.<clinit>(PhoenixConnection.java:149)
at
org.apache.phoenix.query.ConnectionQueryServicesImpl$12.call(ConnectionQueryServicesImpl.java:1924)
at
org.apache.phoenix.query.ConnectionQueryServicesImpl$12.call(ConnectionQueryServicesImpl.java:1896)
at
org.apache.phoenix.util.PhoenixContextExecutor.call(PhoenixContextExecutor.java:77)
at
org.apache.phoenix.query.ConnectionQueryServicesImpl.init(ConnectionQueryServicesImpl.java:1896)
at
org.apache.phoenix.jdbc.PhoenixDriver.getConnectionQueryServices(PhoenixDriver.java:180)
at
org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.connect(PhoenixEmbeddedDriver.java:132)
at org.apache.phoenix.jdbc.PhoenixDriver.connect(PhoenixDriver.java:151)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at phoenixTest.main(phoenixTest.java:16)


Seems more like a JAR file version mismatch issue.
Here are the JAR files that I am using:
Please refer to the screen shot

I have followed all the guidelines for setting up Phoenix at:
https://phoenix.apache.org/installation.html

My connection from Squirrel is working fine...but from Java Program getting
the errors.
-- 
With best Regards:
Ashutosh Sharma

Mime
View raw message