Sunday, 8 September 2013

Cant Start Jetty Spring App With HBase Connection

Cant Start Jetty Spring App With HBase Connection

I am creating a Spring app with Embedded jetty in a one jar package. It is
an api that is back by Hbase. It compiles fines but when I run it:
$ java -jar target/myapp.one-jar.jar
JarClassLoader: Warning: Null manifest from input stream associated with:
lib/javax.inject-1.jar
JarClassLoader: Warning: org/apache/commons/collections/FastHashMap.class
in lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning: org/apache/commons/collections/ArrayStack.class
in lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning:
org/apache/commons/collections/FastHashMap$Values.class in
lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning:
org/apache/commons/collections/FastHashMap$CollectionView$CollectionViewIterator.class
in lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning:
org/apache/commons/collections/FastHashMap$1.class in
lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning:
org/apache/commons/collections/BufferUnderflowException.class in
lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning:
org/apache/commons/collections/FastHashMap$KeySet.class in
lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning:
org/apache/commons/collections/FastHashMap$CollectionView.class in
lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning:
org/apache/commons/collections/FastHashMap$EntrySet.class in
lib/commons-beanutils-1.7.0.jar is hidden by
lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning: org/apache/commons/beanutils/BasicDynaBean.class
in lib/commons-beanutils-core-1.8.0.jar is hidden by
lib/commons-beanutils-1.7.0.jar (with different bytecode)
JarClassLoader: Warning: org/apache/commons/beanutils/BasicDynaClass.class
in lib/commons-beanutils-core-1.8.0.jar is hidden by
lib/commons-beanutils-1.7.0.jar (with different bytecode)
And then, as the Spring context is initializing I get this stack trace
13/09/08 18:57:06 ERROR context.ContextLoader: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'hConnection' defined in class
com.example.myapp.context.Config: Instantiation of bean failed; nested
exception is
org.springframework.beans.factory.BeanDefinitionStoreException: Factory
method [public org.apache.hadoop.hbase.client.HConnection
com.example.myapp.context.Config.hConnection() throws java.lang.Exception]
threw exception; nested exception is java.lang.ExceptionInInitializerError
at
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1025)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:921)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
Are these two related? How do I fix this? Here is my construction of the
hConnection bean:
@Bean
@Named("hConnection")
public HConnection hConnection() throws Exception {
org.apache.hadoop.conf.Configuration configuration = new
org.apache.hadoop.conf.Configuration();
HConnection hConnection =
HConnectionManager.createConnection(configuration);
HTableInterface hTableInterface = hConnection.getTable("vin_database");
hTableInterface.close();
return hConnection;
}
I have to use the fully qualified package name for Hadoop Configuration
because it conflicts with the
org.springframework.context.annotation.Configuration annotation.

No comments:

Post a Comment