title: SPARK Error: java.lang.UnsatisfiedLinkError: /tmp/snappy-1.0.4.1-libsnappyjava
body: <p>I am running <code>CDH 5.16</code> standalone singlenode in a <code>RHEL 7</code> Server.
  I have written a simple spark code that reads a text file from <code>HDFS</code> and load it as parquet file in a separate location in <code>HDFS</code>. But when ever i am running this code in the server(i am using <code>SBT</code> to build jar and deploy it in cluster using spark-submit), following error is thrown:</p>
  
  <pre><code>19/06/07 12:56:04 INFO spark.SparkContext: Running Spark version 1.6.0
  19/06/07 12:56:04 INFO spark.SecurityManager: Changing view acls to: ak_bng
  19/06/07 12:56:04 INFO spark.SecurityManager: Changing modify acls to: ak_bng
  19/06/07 12:56:04 INFO spark.SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(ak_bng); users with modify permissions: Set(ak_bng)
  19/06/07 12:56:05 INFO util.Utils: Successfully started service 'sparkDriver' on port 44220.
  19/06/07 12:56:05 INFO slf4j.Slf4jLogger: Slf4jLogger started
  19/06/07 12:56:05 INFO Remoting: Starting remoting
  19/06/07 12:56:05 INFO Remoting: Remoting started; listening on addresses :[akka.tcp://sparkDriverActorSystem@10.188.223.5:36304]
  19/06/07 12:56:05 INFO Remoting: Remoting now listens on addresses: [akka.tcp://sparkDriverActorSystem@10.188.223.5:36304]
  19/06/07 12:56:05 INFO util.Utils: Successfully started service 'sparkDriverActorSystem' on port 36304.
  19/06/07 12:56:05 INFO spark.SparkEnv: Registering MapOutputTracker
  19/06/07 12:56:05 INFO spark.SparkEnv: Registering BlockManagerMaster
  19/06/07 12:56:05 INFO storage.DiskBlockManager: Created local directory at /tmp/blockmgr-c38a27e3-c483-4f56-ab7f-56e4c1be0832
  19/06/07 12:56:05 INFO storage.MemoryStore: MemoryStore started with capacity 530.0 MB
  19/06/07 12:56:06 INFO spark.SparkEnv: Registering OutputCommitCoordinator
  19/06/07 12:56:06 INFO util.Utils: Successfully started service 'SparkUI' on port 4040.
  19/06/07 12:56:06 INFO ui.SparkUI: Started SparkUI at http://10.188.223.5:4040
  19/06/07 12:56:06 INFO spark.SparkContext: Added JAR file:/home/ak_bng/spark_jars/Simple_Project-assembly-1.0.jar at spark://10.188.223.5:44220/jars/Simple_Project-assembly-1.0.jar with timestamp 1559892366578
  19/06/07 12:56:06 INFO executor.Executor: Starting executor ID driver on host localhost
  19/06/07 12:56:06 INFO util.Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 46170.
  19/06/07 12:56:06 INFO netty.NettyBlockTransferService: Server created on 46170
  19/06/07 12:56:06 INFO storage.BlockManager: external shuffle service port = 7337
  19/06/07 12:56:06 INFO storage.BlockManagerMaster: Trying to register BlockManager
  19/06/07 12:56:06 INFO storage.BlockManagerMasterEndpoint: Registering block manager localhost:46170 with 530.0 MB RAM, BlockManagerId(driver, localhost, 46170)
  19/06/07 12:56:06 INFO storage.BlockManagerMaster: Registered BlockManager
  19/06/07 12:56:07 INFO scheduler.EventLoggingListener: Logging events to hdfs://indelsrv185.in.kworld.kpmg.com:8020/user/spark/applicationHistory/local-1559892366602
  19/06/07 12:56:07 INFO spark.SparkContext: Registered listener com.cloudera.spark.lineage.ClouderaNavigatorListener
  19/06/07 12:56:08 INFO parquet.ParquetRelation: Listing hdfs://10.188.223.5:8020/user/ak_bng/products on driver
  19/06/07 12:56:08 INFO parquet.ParquetRelation: Listing hdfs://10.188.223.5:8020/user/ak_bng/categories on driver
  java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:312)
          at org.xerial.snappy.SnappyLoader.load(SnappyLoader.java:219)
          at org.xerial.snappy.Snappy.&lt;clinit&gt;(Snappy.java:44)
          at org.apache.spark.io.SnappyCompressionCodec$.liftedTree1$1(CompressionCodec.scala:169)
          at org.apache.spark.io.SnappyCompressionCodec$.org$apache$spark$io$SnappyCompressionCodec$$version$lzycompute(CompressionCodec.scala:168)
          at org.apache.spark.io.SnappyCompressionCodec$.org$apache$spark$io$SnappyCompressionCodec$$version(CompressionCodec.scala:168)
          at org.apache.spark.io.SnappyCompressionCodec.&lt;init&gt;(CompressionCodec.scala:152)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          at org.apache.spark.io.CompressionCodec$.createCodec(CompressionCodec.scala:72)
          at org.apache.spark.io.CompressionCodec$.createCodec(CompressionCodec.scala:65)
          at org.apache.spark.broadcast.TorrentBroadcast.org$apache$spark$broadcast$TorrentBroadcast$$setConf(TorrentBroadcast.scala:74)
          at org.apache.spark.broadcast.TorrentBroadcast.&lt;init&gt;(TorrentBroadcast.scala:81)
          at org.apache.spark.broadcast.TorrentBroadcastFactory.newBroadcast(TorrentBroadcastFactory.scala:34)
          at org.apache.spark.broadcast.BroadcastManager.newBroadcast(BroadcastManager.scala:63)
          at org.apache.spark.SparkContext.broadcast(SparkContext.scala:1334)
          at org.apache.spark.sql.execution.datasources.DataSourceStrategy$.apply(DataSourceStrategy.scala:126)
          at org.apache.spark.sql.catalyst.planning.QueryPlanner$$anonfun$1.apply(QueryPlanner.scala:58)
          at org.apache.spark.sql.catalyst.planning.QueryPlanner$$anonfun$1.apply(QueryPlanner.scala:58)
          at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
          at org.apache.spark.sql.catalyst.planning.QueryPlanner.plan(QueryPlanner.scala:59)
          at org.apache.spark.sql.execution.QueryExecution.sparkPlan$lzycompute(QueryExecution.scala:48)
          at org.apache.spark.sql.execution.QueryExecution.sparkPlan(QueryExecution.scala:46)
          at org.apache.spark.sql.execution.QueryExecution.executedPlan$lzycompute(QueryExecution.scala:53)
          at org.apache.spark.sql.execution.QueryExecution.executedPlan(QueryExecution.scala:53)
          at org.apache.spark.sql.execution.QueryExecution$$anonfun$toString$5.apply(QueryExecution.scala:81)
          at org.apache.spark.sql.execution.QueryExecution$$anonfun$toString$5.apply(QueryExecution.scala:81)
          at org.apache.spark.sql.execution.QueryExecution.stringOrError(QueryExecution.scala:61)
          at org.apache.spark.sql.execution.QueryExecution.toString(QueryExecution.scala:81)
          at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:50)
          at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelation.run(InsertIntoHadoopFsRelation.scala:106)
          at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult$lzycompute(commands.scala:58)
          at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult(commands.scala:56)
          at org.apache.spark.sql.execution.ExecutedCommand.doExecute(commands.scala:70)
          at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:132)
          at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:130)
          at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
          at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:130)
          at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:56)
          at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:56)
          at org.apache.spark.sql.execution.datasources.ResolvedDataSource$.apply(ResolvedDataSource.scala:256)
          at org.apache.spark.sql.DataFrameWriter.dataSource$lzycompute$1(DataFrameWriter.scala:181)
          at org.apache.spark.sql.DataFrameWriter.org$apache$spark$sql$DataFrameWriter$$dataSource$1(DataFrameWriter.scala:181)
          at org.apache.spark.sql.DataFrameWriter$$anonfun$save$1.apply$mcV$sp(DataFrameWriter.scala:188)
          at org.apache.spark.sql.DataFrameWriter.executeAndCallQEListener(DataFrameWriter.scala:154)
          at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:188)
          at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:172)
          at org.apache.spark.sql.DataFrameWriter.parquet(DataFrameWriter.scala:370)
          at SimpleApp$.main(SimpleApp.scala:169)
          at SimpleApp.main(SimpleApp.scala)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:730)
          at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
          at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
          at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
          at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
  Caused by: java.lang.UnsatisfiedLinkError: /tmp/snappy-1.0.4.1-libsnappyjava.so: /tmp/snappy-1.0.4.1-libsnappyjava.so: failed to map segment from shared object: Operation not permitted
          at java.lang.ClassLoader$NativeLibrary.load(Native Method)
          at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
          at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
          at java.lang.Runtime.load0(Runtime.java:809)
          at java.lang.System.load(System.java:1086)
          at org.xerial.snappy.SnappyNativeLoader.load(SnappyNativeLoader.java:39)
          ... 65 more
  Exception in thread "main" java.lang.IllegalArgumentException: java.lang.NoClassDefFoundError: Could not initialize class org.xerial.snappy.Snappy
          at org.apache.spark.io.SnappyCompressionCodec$.liftedTree1$1(CompressionCodec.scala:171)
          at org.apache.spark.io.SnappyCompressionCodec$.org$apache$spark$io$SnappyCompressionCodec$$version$lzycompute(CompressionCodec.scala:168)
          at org.apache.spark.io.SnappyCompressionCodec$.org$apache$spark$io$SnappyCompressionCodec$$version(CompressionCodec.scala:168)
          at org.apache.spark.io.SnappyCompressionCodec.&lt;init&gt;(CompressionCodec.scala:152)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          at org.apache.spark.io.CompressionCodec$.createCodec(CompressionCodec.scala:72)
          at org.apache.spark.io.CompressionCodec$.createCodec(CompressionCodec.scala:65)
          at org.apache.spark.broadcast.TorrentBroadcast.org$apache$spark$broadcast$TorrentBroadcast$$setConf(TorrentBroadcast.scala:74)
          at org.apache.spark.broadcast.TorrentBroadcast.&lt;init&gt;(TorrentBroadcast.scala:81)
          at org.apache.spark.broadcast.TorrentBroadcastFactory.newBroadcast(TorrentBroadcastFactory.scala:34)
          at org.apache.spark.broadcast.BroadcastManager.newBroadcast(BroadcastManager.scala:63)
          at org.apache.spark.SparkContext.broadcast(SparkContext.scala:1334)
          at org.apache.spark.sql.execution.datasources.DataSourceStrategy$.apply(DataSourceStrategy.scala:126)
          at org.apache.spark.sql.catalyst.planning.QueryPlanner$$anonfun$1.apply(QueryPlanner.scala:58)
          at org.apache.spark.sql.catalyst.planning.QueryPlanner$$anonfun$1.apply(QueryPlanner.scala:58)
          at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
          at org.apache.spark.sql.catalyst.planning.QueryPlanner.plan(QueryPlanner.scala:59)
          at org.apache.spark.sql.execution.QueryExecution.sparkPlan$lzycompute(QueryExecution.scala:48)
          at org.apache.spark.sql.execution.QueryExecution.sparkPlan(QueryExecution.scala:46)
          at org.apache.spark.sql.execution.QueryExecution.executedPlan$lzycompute(QueryExecution.scala:53)
          at org.apache.spark.sql.execution.QueryExecution.executedPlan(QueryExecution.scala:53)
          at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:51)
          at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelation.run(InsertIntoHadoopFsRelation.scala:106)
          at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult$lzycompute(commands.scala:58)
          at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult(commands.scala:56)
          at org.apache.spark.sql.execution.ExecutedCommand.doExecute(commands.scala:70)
          at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:132)
          at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:130)
          at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
          at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:130)
          at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:56)
          at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:56)
          at org.apache.spark.sql.execution.datasources.ResolvedDataSource$.apply(ResolvedDataSource.scala:256)
          at org.apache.spark.sql.DataFrameWriter.dataSource$lzycompute$1(DataFrameWriter.scala:181)
          at org.apache.spark.sql.DataFrameWriter.org$apache$spark$sql$DataFrameWriter$$dataSource$1(DataFrameWriter.scala:181)
          at org.apache.spark.sql.DataFrameWriter$$anonfun$save$1.apply$mcV$sp(DataFrameWriter.scala:188)
          at org.apache.spark.sql.DataFrameWriter.executeAndCallQEListener(DataFrameWriter.scala:154)
          at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:188)
          at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:172)
          at org.apache.spark.sql.DataFrameWriter.parquet(DataFrameWriter.scala:370)
          at SimpleApp$.main(SimpleApp.scala:169)
          at SimpleApp.main(SimpleApp.scala)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:730)
          at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
          at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
          at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
          at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
  Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.xerial.snappy.Snappy
          at org.apache.spark.io.SnappyCompressionCodec$.liftedTree1$1(CompressionCodec.scala:169)
          ... 53 more
  19/06/07 12:56:08 INFO spark.SparkContext: Invoking stop() from shutdown hook
  19/06/07 12:56:08 INFO ui.SparkUI: Stopped Spark web UI at http://10.188.223.5:4040
  19/06/07 12:56:08 INFO spark.MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
  19/06/07 12:56:09 INFO storage.MemoryStore: MemoryStore cleared
  19/06/07 12:56:09 INFO storage.BlockManager: BlockManager stopped
  19/06/07 12:56:09 INFO storage.BlockManagerMaster: BlockManagerMaster stopped
  19/06/07 12:56:09 INFO scheduler.OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
  19/06/07 12:56:09 INFO remote.RemoteActorRefProvider$RemotingTerminator: Shutting down remote daemon.
  19/06/07 12:56:09 INFO remote.RemoteActorRefProvider$RemotingTerminator: Remote daemon shut down; proceeding with flushing remote transports.
  19/06/07 12:56:09 INFO Remoting: Remoting shut down
  19/06/07 12:56:09 INFO remote.RemoteActorRefProvider$RemotingTerminator: Remoting shut down.
  19/06/07 12:56:09 INFO spark.SparkContext: Successfully stopped SparkContext
  19/06/07 12:56:09 INFO util.ShutdownHookManager: Shutdown hook called
  19/06/07 12:56:09 INFO util.ShutdownHookManager: Deleting directory /tmp/spark-111712ef-39a8-41b6-bf6d-5d317d954fa1
  
  </code></pre>
  
  <p>spark submit command:
  <code>spark-submit --class SimpleApp --master local[8]  /home/ak_bng/spark_jars/Simple_Project-assembly-1.0.jar</code>.</p>
  
  <p>I went through few links to resolve this issue(<a href="https://stackoverflow.com/questions/47211407/snappy-compression-not-working-due-to-tmp-folder-previliges">Snappy Compression not working due to tmp folder previliges</a>, <a href="https://stackoverflow.com/questions/44063940/apache-spark-parquet-snappy-compression-error">Apache Spark - Parquet / Snappy compression error</a>, ) but none couldn't really provide a solution for this.</p>
  
  <p>I had run Spark on <code>HDFS</code> (separate installation) successfully without any errors before. The problem started coming once <code>CDH</code>was installed.
  I am new to setting up cluster and quite don't understand what the issue is here and how to resolve it. Can some one help please shed some light on this.</p>
  
  <p>I am using:</p>
  
  <pre><code>CDH 5.16
  Spark 1.6.0
  Server OS: RHEL 7
  Hadoop 2.6
  </code></pre>