Usually in the Windows environment to develop, in the Windows environment Operation HBase may be an exception (Java.io.IOException:Could not locate executable null\bin\ Winutils.exe in the Hadoop binaries.), have encountered this problem before, and today there are small partners encountered this problem, incidentally, the exception information is as follows:
2016-05-23 17:02:13,551 WARN [Org.apache.hadoop.util.NativeCodeLoader]-Unable to load Native-hadoop library for you R platform ... using Builtin-java classes where applicable2016-05-23 17:02:13,611 ERROR [Org.apache.hadoop.util.Shell]-F Ailed to locate the winutils binary in the Hadoop binary pathjava.io.IOException:Could not locate executable Null\bin\win Utils.exe in the Hadoop binaries. At Org.apache.hadoop.util.Shell.getQualifiedBinPath (shell.java:278) at Org.apache.hadoop.util.Shell.getWinUtilsPath (shell.java:300) at Org.apache.hadoop.util.Shell.<Clinit>(shell.java:293) at org.apache.hadoop.util.StringUtils.<Clinit>(stringutils.java:76) at Org.apache.hadoop.conf.Configuration.getStrings (configuration.java:1514) at Org.apache.hadoop.hbase.zookeeper.ZKConfig.makeZKProps (zkconfig.java:113) at Org.apache.hadoop.hbase.zookeeper.ZKConfig.getZKQuorumServersString (zkconfig.java:265) at Org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<Init>(zookeeperwatcher.java:159) at Org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<Init>(zookeeperwatcher.java:134) at org.apache.hadoop.hbase.client.ZooKeeperKeepAliveConnection.<Init>(zookeeperkeepaliveconnection.java:43) at org.apache.hadoop.hbase.client.hconnectionmanager$ Hconnectionimplementation.getkeepalivezookeeperwatcher (hconnectionmanager.java:1710) at Org.apache.hadoop.hbase.client.ZooKeeperRegistry.getClusterId (zookeeperregistry.java:82) at Org.apache.hadoop.hbase.client.hconnectionmanager$hconnectionimplementation.retrieveclusterid ( hconnectionmanager.java:806) at org.apache.hadoop.hbase.client.hconnectionmanager$hconnectionimplementation.<Init>(hconnectionmanager.java:633) at Sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method) at Sun.refle Ct. Nativeconstructoraccessorimpl.newinstance (nativeconstructoraccessorimpl.java:57) at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (delegatingconstructoraccessorimpl.java:45) at Java.lang.reflect.Constructor.newInstance (constructor.java:526) at Org.apache.hadoop.hbase.client.HConnectionManager.createConnection (hconnectionmanager.java:387) at Org.apache.hadoop.hbase.client.HConnectionManager.createConnection (hconnectionmanager.java:282) at Net.shgaoxin.db.hbase.HbaseConnectionFactory.createResource (hbaseconnectionfactory.java:67) at Net.shgaoxin.db.hbase.HbaseConnectionFactory.makeObject (hbaseconnectionfactory.java:40) at Org.apache.commons.pool2.impl.GenericObjectPool.create (genericobjectpool.java:868) at Org.apache.commons.pool2.impl.GenericObjectPool.borrowObject (genericobjectpool.java:435) at Org.apache.commons.pool2.impl.GeNericobjectpool.borrowobject (genericobjectpool.java:363) at Net.shgaoxin.base.AbstractPooledContainer.get ( abstractpooledcontainer.java:49) at Net.shgaoxin.db.hbase.HbaseConnectionContainer.getConnection ( hbaseconnectioncontainer.java:46) at Net.shgaoxin.db.hbase.HbaseConnectionContainer.getConnection ( HBASECONNECTIONCONTAINER.JAVA:14) at Net.shgaoxin.db.hbase.HbaseTemplate.scan (hbasetemplate.java:398) at Net.shgaoxin.impl.dao.hbase.GenericDaoHbaseImpl.scan (genericdaohbaseimpl.java:73) at Net.shgaoxin.impl.service.eastdayminisitesp.ImgUploadServiceImpl.getCurrentStepRowkeys ( imguploadserviceimpl.java:260) at Net.shgaoxin.impl.context.eastdayminisitesp.AsyncImgUploadContextImpl.doOnStart (Asyncimguploadcontextimpl.java : Bayi) at Net.shgaoxin.impl.context.AbstractProcessQueue.start (abstractprocessqueue.java:119) at SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:57) at Sun.reFlect. Delegatingmethodaccessorimpl.invoke (delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke ( method.java:606)
View Hadoop Source code:
/**fully qualify the path to a binary that should is in a known Hadoop * bin location. This was primarily useful for disambiguating call-outs * to executable sub-components of Hadoop to avoid clashes with O ther * Executables that may is in the path. Caveat:this call doesn ' t * just format the path to the bin directory. It also checks for file * Existence of the composed path. The output of this call should is * cached by callers. * */ Public Static Finalstring Getqualifiedbinpath (string executable)throwsIOException {//construct Hadoop bin path to the specified executable String fullexename = hadoop_home_dir + file.separator + "bin" + File.separator + executable; File Exefile=NewFile (fullexename); if(!exefile.exists ()) { Throw NewIOException ("Could not locate executable" +Fullexename+ "in the Hadoop binaries."); } returnExefile.getcanonicalpath (); }
private static String Hadoop_home_dir =Checkhadoophome (); /** centralized logic to discover and validate the sanity of the Hadoop * home directory. Returns either NULL or a directory that exists and * is specified via Either-dhadoop.home.dir or the Hadoop_home ENV * variable. This does a lot of work so it should is called * privately for initialization once per process. **/private staticString Checkhadoophome () {//first check the Dflag hadoop.home.dir with JVM scope String home = System.getproperty ( "Hadoop.home.dir"); Fall back to the System/user-global env variable if (home = = NULL{home = system.getenv ("Hadoop_home")); } try {//couldn ' t find either setting for Hadoop ' s home directory if (home = = null ) {throw new Ioexcepti On ("Hadoop_home or Hadoop.home.dir is not set.") ); } if (Home.startswith ("\") && Home.endswith ("\" ")") {home = home.substring (1, Home.length ()-1 );}// Check the home setting is actually a directory that exists file Homedir = new file (home); if (!homedir.isabsol Ute () | | !homedir.exists () | | ! homedir.isdirectory ()) {throw new IOException ("Hadoop home directory" + Homedir + "does not exist, was not a directory, or was not a ABSO lute path. " ); } home = homedir.getcanonicalpath ();} catch (IOException IoE) {if (log.isdebugenabled ()) {Log.debug (" Failed to detect a valid Hadoop home directory ", IOE); home = null ;} return home,}
Combined with the exception is not difficult to find Hadoop_home_dir value is null, basically can be judged to be the problem of hadoop_home environment variables, in fact, there is no environment variable configuration HADOOP, error is taken for granted.
Configuring Windows environment variables requires a winutils.exe, and the great God provides a file required for the environment configuration under Windows, refer to Https://github.com/srccodes/hadoop-common-2.2.0-bin
HBase exception is used in Windows: Java.io.IOException:Could not locate executable null\bin\winutils.exe in the Hadoop binaries.