The following worked:
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CodingErrorAction;
public static Charset charset = Charset.forName("UTF-8");
public static CharsetEncoder encoder = charset.newEncoder();
public static CharsetDecoder decoder = charset.newDecoder();
public static ByteBuffer str_to_bb(String msg){
    return encoder.encode(CharBuffer.wrap(msg));
  }catch(Exception e){e.printStackTrace();}
  return null;
and then instead of "count_key".getBytes("UTF-8")

On Tue, Dec 20, 2011 at 4:03 PM, Dave Brosius <> wrote:
A ByteBuffer is not a byte[] to convert a String to a ByteBuffer do something like

public static ByteBuffer toByteBuffer(String value) 
    throws UnsupportedEncodingException
        return ByteBuffer.wrap(value.getBytes("UTF-8"));


----- Original Message -----
From: "A J" <>
Sent: Tue, December 20, 2011 15:52
Subject: java thrift error

The following syntax :
import org.apache.cassandra.thrift.*;
ColumnOrSuperColumn col = client.get("count_key".getBytes("UTF-8"),
cp, ConsistencyLevel.QUORUM);

is giving the error:
in org.apache.cassandra.thrift.Cassandra.Client cannot be applied to

Any idea on how to cast?