title: Error implementing the Thrift API
body: <p>I'm implementing the Thrift Remote Procedure call framework in Java. I set up thrift and generated my skeleton code without a lot of issues, but now that I'm actually using the API methods, I get strange errors. </p>
  
  <p>Here are the errors I get: </p>
  
  <pre><code>Exception in thread "main" org.apache.thrift.transport.TTransportException: Cannot write to null outputStream
  at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:142)
  at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:163)
  at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:91)
  at SimonSays$Client.send_registerClient(SimonSays.java:102)
  at SimonSays$Client.registerClient(SimonSays.java:96)
  at simon.main(testClass.java:16)
  </code></pre>
  
  <p>I don't think I'm not making any mistakes, but just to make sure, here's the code that's leading to the errors: </p>
  
  <pre><code>TProtocol prot = new TBinaryProtocol(new TSocket("http://thriftpuzzle.facebook.com",9030));
      SimonSays.Client client = new SimonSays.Client(prot);
  
      client.registerClient("userEmailAddress@gmail.com");
  </code></pre>
  
  <p>The error is said to be generated from the <code>client.registerClient()</code> call, but that is a call to the code generated by Thrift, which makes me feel that I'm doing something wrong in setting up the connection itself. </p>
  
  <p>The part about making a <code>TProtocol</code> instance I included myself, and it's likely that that's where the problem lies. </p>
  
  <p>I was hoping that someone would have more of an idea about what's going wrong that I do.</p>
  
  <p>Please let me know if more information or clarification is needed.  </p>
  
  <p>Edit: I found the <code>TProtocol</code> instantiation statement from the <a href="http://wiki.apache.org/cassandra/ThriftExamples03" rel="nofollow">Cassandra Wiki</a></p>