Fork me on GitHub

Sunday, April 7, 2013

Fix "Cannot initialize native Snappy library. Compression on new tables will be disabled." with DSC Cassandra 1.2.3 under OS X with Java 1.7

When setting up an OS X 10.8.3 development machine that was already updated to the latest Java 1.7 SDK, I got the following error when starting up DataStax Community Edition Cassandra 1.2.3:

 java.lang.reflect.InvocationTargetException  
 Googling the error brought me to:   
 To quickly fix the issue, from $CASSADRA_HOME:  
  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:601)  
  at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:317)  
  at org.xerial.snappy.SnappyLoader.load(SnappyLoader.java:219)  
  at org.xerial.snappy.Snappy.(Snappy.java:44)  
  at org.apache.cassandra.io.compress.SnappyCompressor.create(SnappyCompressor.java:45)  
  at org.apache.cassandra.io.compress.SnappyCompressor.isAvailable(SnappyCompressor.java:55)  
  at org.apache.cassandra.io.compress.SnappyCompressor.(SnappyCompressor.java:37)  
  at org.apache.cassandra.config.CFMetaData.(CFMetaData.java:82)  
  at org.apache.cassandra.config.KSMetaData.systemKeyspace(KSMetaData.java:81)  
  at org.apache.cassandra.config.DatabaseDescriptor.loadYaml(DatabaseDescriptor.java:476)  
  at org.apache.cassandra.config.DatabaseDescriptor.(DatabaseDescriptor.java:123)  
  at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:182)  
  at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:398)  
  at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:441)  
 Caused by: java.lang.UnsatisfiedLinkError: no snappyjava in java.library.path  
  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)  
  at java.lang.Runtime.loadLibrary0(Runtime.java:845)  
  at java.lang.System.loadLibrary(System.java:1084)  
  at org.xerial.snappy.SnappyNativeLoader.loadLibrary(SnappyNativeLoader.java:52)  
  ... 17 more  
  WARN 15:36:20,720 Cannot initialize native Snappy library. Compression on new tables will be disabled.  

Googling the error brought me to:
https://github.com/ptaoussanis/carmine/issues/5
...which nicely points out that Snappy 1.0.5 fixes the issue (DSC 1.2.3 ships with snappy-java-1.0.4.1).

To quickly fix the issue, from $CASSANDRA_HOME:

cd lib
rm snappy-java-1.0.4.1.jar
wget https://snappy-java.googlecode.com/files/snappy-java-1.0.5-M4.jar