2

I have been trying to develop a web-app which takes data through rest and inserts the same data in hbase using phoenix. I have tried to deploy my application on tomcat and it works fine. But is throws the following runtime exception while deploying it on jboss.

Caused by: java.lang.RuntimeException: hbase-default.xml file seems to be for and old version of HBase (null), this version is 0.94.7 at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:68) at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:100) at org.apache.hadoop.hbase.HBaseConfiguration.create(HBaseConfiguration.java:111) at com.salesforce.phoenix.query.ConfigurationFactory$ConfigurationFactoryImpl.getConfiguration(ConfigurationFactory.java:51) at com.salesforce.phoenix.query.QueryServicesOptions.withDefaults(QueryServicesOptions.java:99) at com.salesforce.phoenix.query.QueryServicesImpl.(QueryServicesImpl.java:44) at com.salesforce.phoenix.jdbc.PhoenixDriver.(PhoenixDriver.java:67) at com.salesforce.phoenix.jdbc.PhoenixDriver.(PhoenixDriver.java:58) ... 11 more

First i thought that class path has two default xmls and its throwing the error because one of the two is from some older version of hbase jar. But the class path has no hbase jar. It only has one phoenix-2.0.1-client.jar. I have tried the following things after that

  1. Setting "hbase.default.for.version.skip" to true in hbase-site.xml and adding that to class path
  2. Setting "hbase.default.for.version.skip" to true in hbase-default.xml
  3. Just for experiment's sake i also tried deleting the hbase-default.xml.

Nothing has worked so far. The result being constant. I am using cloudera hbase cdh 4.4 . Any help would be extremely appreciated. Thanks in advance.

1 Answers1

0

Related: https://groups.google.com/forum/#!topic/phoenix-hbase-user/GpeGDDjEH_g

the solution seems to be to remove META-INF/services/java.sql.Driver from the phoenix--client.jar (or phoenix-core-.jar ) and instead use Class.forName("com.salesforce.phoenix.jdbc.PhoenixDriver") in your code somewhere (before trying to open a connection) as Jboss seems to reorder the jars differently from tomcat.

this worked for me (assuming phoenix is installed in a local maven repository):

mkdir /tmp/myjar 
cd /tmp/myjar  
cp ~/.m2/repository/com/salesforce/phoenix-core/3.0.0-SNAPSHOT/phoenix-core-3.0.0-SNAPSHOT.jar ./
jar -xvf phoenix-core-3.0.0-SNAPSHOT.jar
rm META-INF/services/java.sql.Driver 
rm phoenix-core-3.0.0-SNAPSHOT.jar
jar -cvf phoenix-core-3.0.0-SNAPSHOT.jar  ./
cp phoenix-core-3.0.0-SNAPSHOT.jar ~/.m2/repository/com/salesforce/phoenix-core/3.0.0-SNAPSHOT/

re-build the webapp  and deploy to Jboss:
cd ~/phoenix-restservice
mvn clean install

additional trick for JBoss/Phoenix integration - Jboss throws this error as it includes Resteasy JAX-RS implementation by default and Hbase uses Jersey JAX-RS jars which causes a collision ( as in Deploying a Jersey webapp on Jboss AS 7):

 "org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011232: Only one JAX-RS Application Class allowed"

to fix add to ~/your_phoenix_restservice/src/main/webapp/WEB-INF/web.xml:

<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>resteasy.scan.providers</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>resteasy.scan.resources</param-name>
    <param-value>false</param-value>
</context-param>

also it's a good idea to initialize hbase connection on startup, this can be done using InitServlet as described in JBoss at Work: A Practical Guide, p.260

as a side note do you mind open-sourcing your version of rest api for phoenix? this would be helpful for us and a bunch of other people.

Community
  • 1
  • 1
alex
  • 1,757
  • 4
  • 21
  • 32