有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法通过spring项目与Hbase交互

从早上开始尝试,现在真的需要帮助才能开始。 Ubuntu 14.04 64位版本 已安装hadoop/hbase最新版本。使用伪分布式模式

核心网站。xml

<configuration>
 <property>
  <name>hadoop.tmp.dir</name>
  <value>/app/hadoop/tmp</value>
  <description>A base for other temporary directories.</description>
 </property>

 <property>
  <name>fs.default.name</name>
  <value>hdfs://localhost:54310</value>
  <description>Some text...</description>
 </property>
</configuration>

hdfs网站。xml

<configuration>
 <property>
  <name>dfs.replication</name>
  <value>1</value>
  <description>Default block replication.
  The actual number of replications can be specified when the file is created.
  The default is used if replication is not specified in create time.
  </description>
 </property>
 <property>
   <name>dfs.namenode.name.dir</name>
   <value>file:/usr/local/hadoop_store/hdfs/namenode</value>
 </property>
 <property>
   <name>dfs.datanode.data.dir</name>
   <value>file:/usr/local/hadoop_store/hdfs/datanode</value>
 </property>
</configuration>

hbase网站。xml 没有明确的zookeeper安装

<configuration>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>

    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://localhost:54310/hbase</value>
    </property>

    <property>
        <name>hbase.zookeeper.quoram</name>
        <value>localhost</value>
    </property>

    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>    
</configuration>

春季项目详情-

mvc配置。xml-

<hdp:configuration id="hadoopConfiguration">
        fs.default.name=hdfs://localhost:54310
    </hdp:configuration>

    <!-- hbase configuration -->
    <hdp:hbase-configuration configuration-ref="hadoopConfiguration"
        zk-quorum="localhost" zk-port="2181" />

    <bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
        <property name="configuration" ref="hbaseConfiguration" />
    </bean>

DAO实现-

@Autowired
    private HbaseTemplate hbaseTemplate;
    private String tableName = "test";
    public static byte[] CF_INFO = Bytes.toBytes("cf");
    private byte[] qUser = Bytes.toBytes("a");
    private byte[] qEmail = Bytes.toBytes("email");
public Object save(URLModel urlParam) {
        final URLModel url = urlParam;
        return hbaseTemplate.execute(tableName, new TableCallback<Object>() {
            public Object doInTable(HTableInterface table) throws Throwable {               
                Put p = new Put(Bytes.toBytes(url.getUrl()));
                p.add(CF_INFO, qUser, Bytes.toBytes(url.getUrl()));
                p.add(CF_INFO, qEmail, Bytes.toBytes(url.getEmail()));
                table.put(p);
                return null;
            }
        });

JPS输出-

7785 HMaster
3421 NodeManager
7946 HRegionServer
7720 HQuorumPeer
3140 SecondaryNameNode
2803 NameNode
3294 ResourceManager
2927 DataNode
10647 Jps

fuser 2181/tcp
2181/tcp:             7720

现在的问题是,当我点击save按钮,我的控制器将其带到save代码时,什么都没有发生,页面继续无限加载。没有异常,也没有存储数据

输出 bin/hbase zkcli-服务器本地主机:2181

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Connecting to localhost:2181
2014-10-05 17:33:36,172 INFO  [main] zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2014-10-05 17:33:36,173 INFO  [main] zookeeper.ZooKeeper: Client environment:host.name=anurag-dev
2014-10-05 17:33:36,173 INFO  [main] zookeeper.ZooKeeper: Client environment:java.version=1.7.0_67
2014-10-05 17:33:36,173 INFO  [main] zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation
2014-10-05 17:33:36,173 INFO  [main] zookeeper.ZooKeeper: Client environment:java.home=/usr/lib/jvm/java-7-oracle/jre
2014-10-05 17:33:36,173 INFO  [main] zookeeper.ZooKeeper: Client environment:java.class.path=...lots of jars
2014-10-05 17:33:36,174 INFO  [main] zookeeper.ZooKeeper: Client environment:java.library.path=/usr/local/hadoop/lib
2014-10-05 17:33:36,174 INFO  [main] zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp
2014-10-05 17:33:36,175 INFO  [main] zookeeper.ZooKeeper: Client environment:java.compiler=<NA>
2014-10-05 17:33:36,175 INFO  [main] zookeeper.ZooKeeper: Client environment:os.name=Linux
2014-10-05 17:33:36,175 INFO  [main] zookeeper.ZooKeeper: Client environment:os.arch=amd64
2014-10-05 17:33:36,175 INFO  [main] zookeeper.ZooKeeper: Client environment:os.version=3.13.0-24-generic
2014-10-05 17:33:36,175 INFO  [main] zookeeper.ZooKeeper: Client environment:user.name=hduser
2014-10-05 17:33:36,175 INFO  [main] zookeeper.ZooKeeper: Client environment:user.home=/home/hduser
2014-10-05 17:33:36,175 INFO  [main] zookeeper.ZooKeeper: Client environment:user.dir=/usr/local/hbase
2014-10-05 17:33:36,178 INFO  [main] zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@438e9e9
Welcome to ZooKeeper!
2014-10-05 17:33:36,391 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2014-10-05 17:33:36,559 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session
JLine support is enabled
2014-10-05 17:33:36,716 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x148dfa216b7000c, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

猫卡特琳娜。出去

INFO: Loading XML bean definitions from class path resource [spring/application-config.xml]
Oct 05, 2014 5:14:50 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@36dfe178: defining beans []; root of factory hierarchy
Oct 05, 2014 5:14:50 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 578 ms
Oct 05, 2014 5:14:50 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'dispatcherServlet': initialization started
Oct 05, 2014 5:14:50 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'dispatcherServlet-servlet': startup date [Sun Oct 05 17:14:50 IST 2014]; parent: Root WebApplicationContext
Oct 05, 2014 5:14:50 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-config.xml]
Oct 05, 2014 5:14:50 PM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Oct 05, 2014 5:14:50 PM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-330 'javax.inject.Named' annotation found and supported for component scanning
Oct 05, 2014 5:14:50 PM org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor <init>
INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
Oct 05, 2014 5:14:50 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3a77c2d: defining beans [homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.view.InternalResourceViewResolver#0,urlDao,dataSource,hadoopConfiguration,hbaseConfiguration,hbaseTemplate,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@36dfe178
Oct 05, 2014 5:14:50 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
Oct 05, 2014 5:14:51 PM org.apache.hadoop.conf.Configuration warnOnceIfDeprecated
INFO: fs.default.name is deprecated. Instead, use fs.defaultFS
Oct 05, 2014 5:14:51 PM org.springframework.data.hadoop.hbase.HbaseConfigurationFactoryBean setStopProxy
WARNING: Use of 'stopProxy' has been deprecated
Oct 05, 2014 5:14:51 PM org.apache.hadoop.conf.Configuration warnOnceIfDeprecated
INFO: fs.default.name is deprecated. Instead, use fs.defaultFS
Oct 05, 2014 5:14:51 PM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/showMessage.html],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.data.hello.controller.HomeController.showAddUrlPage(org.springframework.web.servlet.ModelAndView) throws java.io.IOException
Oct 05, 2014 5:14:51 PM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/saveUrl],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.data.hello.controller.HomeController.actionAddUrl(com.data.hello.model.URLModel,org.springframework.web.servlet.ModelAndView)
Oct 05, 2014 5:14:51 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'dispatcherServlet': initialization completed in 1495 ms
Oct 05, 2014 5:14:51 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Oct 05, 2014 5:14:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Oct 05, 2014 5:14:52 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 23851 ms
Oct 05, 2014 5:14:53 PM org.apache.hadoop.util.NativeCodeLoader <clinit>
WARNING: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
INFO  ZooKeeper - Client environment:zookeeper.version=3.4.3-1240972, built on 02/06/2012 10:48 GMT
INFO  ZooKeeper - Client environment:host.name=anurag-dev
INFO  ZooKeeper - Client environment:java.version=1.7.0_65
INFO  ZooKeeper - Client environment:java.vendor=Oracle Corporation
INFO  ZooKeeper - Client environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
INFO  ZooKeeper - Client environment:java.class.path=/usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
INFO  ZooKeeper - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
INFO  ZooKeeper - Client environment:java.io.tmpdir=/tmp/tomcat7-tomcat7-tmp
INFO  ZooKeeper - Client environment:java.compiler=<NA>
INFO  ZooKeeper - Client environment:os.name=Linux
INFO  ZooKeeper - Client environment:os.arch=amd64
INFO  ZooKeeper - Client environment:os.version=3.13.0-24-generic
INFO  ZooKeeper - Client environment:user.name=tomcat7
INFO  ZooKeeper - Client environment:user.home=/usr/share/tomcat7
INFO  ZooKeeper - Client environment:user.dir=/var/lib/tomcat7
INFO  ZooKeeper - Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
INFO  ClientCnxn - Opening socket connection to server /127.0.0.1:2181
Oct 05, 2014 5:14:53 PM org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper <init>
INFO: The identifier of this process is 10244@anurag-dev
INFO  ZooKeeperSaslClient - Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.
INFO  ClientCnxn - Socket connection established to localhost/127.0.0.1:2181, initiating session
INFO  ClientCnxn - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x148dfa216b7000a, negotiated timeout = 90000

波姆。xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework.samples.service.service</groupId>
    <artifactId>DataHello</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>

        <!-- Generic properties -->
        <java.version>1.6</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Web -->
        <jsp.version>2.2</jsp.version>
        <jstl.version>1.2</jstl.version>
        <servlet.version>2.5</servlet.version>


        <!-- Spring -->
        <spring-framework.version>3.2.3.RELEASE</spring-framework.version>

        <!-- Hibernate / JPA -->
        <hibernate.version>4.2.1.Final</hibernate.version>

        <!-- Logging -->
        <logback.version>1.0.13</logback.version>
        <slf4j.version>1.7.5</slf4j.version>

        <!-- Test -->
        <junit.version>4.11</junit.version>

        <!-- hadoop/hbase -->
        <spring.hadoop.version>2.0.2.RELEASE</spring.hadoop.version>
        <hadoop.version>1.2.1</hadoop.version>
        <hbase.version>0.92.1</hbase.version>

    </properties>

    <dependencies>

        <!-- Spring MVC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <!-- hadoop habse -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-hadoop</artifactId>
            <version>${spring.hadoop.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context-support</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>${hadoop.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase</artifactId>
            <version>${hbase.version}</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <!-- Other Web dependencies -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Spring and Transactions -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <!-- Logging with SLF4J & LogBack -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.30</version>
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>


        <!-- Test Artifacts -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring-framework.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
</project>

如果分享其他东西能解决问题,请告诉我

这里的任何信息都将非常可观

-AJ


共 (0) 个答案