Java 错误org.apache.thrift.server.TSimpleServer-处理消息时出错

Java 错误org.apache.thrift.server.TSimpleServer-处理消息时出错,java,c#,exception,thrift,Java,C#,Exception,Thrift,我使用的是Thrift(Java服务器、C#client)。 我得到这个错误thift.Transport.ttTransportException。我一直在调试,程序在以下位置停止: TMessage msg = iprot_.ReadMessageBegin(); 在C#methodrecv_getCopii()中,由thrift生成的服务中: public List<Copil> getCopii(Proba proba) { #if !SILVERLIGHT

我使用的是Thrift(Java服务器、C#client)。 我得到这个错误thift.Transport.ttTransportException。我一直在调试,程序在以下位置停止:

   TMessage msg = iprot_.ReadMessageBegin(); 
在C#methodrecv_getCopii()中,由thrift生成的服务中:

public List<Copil> getCopii(Proba proba)
{
  #if !SILVERLIGHT
  send_getCopii(proba);
  return recv_getCopii();

  #else
  var asyncResult = Begin_getCopii(null, null, proba);
  return End_getCopii(asyncResult);

  #endif
}
#if SILVERLIGHT
public IAsyncResult send_getCopii(AsyncCallback callback, object state, Proba proba)
#else
public void send_getCopii(Proba proba)
#endif
{
  oprot_.WriteMessageBegin(new TMessage("getCopii", TMessageType.Call, seqid_));
  getCopii_args args = new getCopii_args();
  args.Proba = proba;
  args.Write(oprot_);
  oprot_.WriteMessageEnd();
  #if SILVERLIGHT
  return oprot_.Transport.BeginFlush(callback, state);
  #else
  oprot_.Transport.Flush();
  #endif
}

public List<Copil> recv_getCopii()
{
  TMessage msg = iprot_.ReadMessageBegin();
  if (msg.Type == TMessageType.Exception) {
    TApplicationException x = TApplicationException.Read(iprot_);
    iprot_.ReadMessageEnd();
    throw x;
  }
  getCopii_result result = new getCopii_result();
  result.Read(iprot_);
  iprot_.ReadMessageEnd();
  if (result.__isset.success) {
    return result.Success;
  }
  if (result.__isset.ce) {
    throw result.Ce;
  }
  throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "getCopii failed: unknown result");
}

您尝试过如何调试?似乎问题出在
java.lang.NullPointerException
上?java代码正在抛出异常。看起来C#客户端没有正确发送Java服务器所期望的数据。您是否分析了Java服务器上的日志,以查看哪个字段或属性为null并导致错误?问题在于函数getCopii()存在,因为如果我创建一个新对象、一个模拟列表并将其发送给客户端,它就会工作。。。问题出在
TMessage msg=iprot_2;.ReadMessageBegin()@Dana:不,你错了。问题不在于
TMessage msg=iprot_u2;.ReadMessageBegin()。查看错误日志中的第一行,它清楚地表明,
18717[main]error org.apache.thrift.server.TSimpleServer-在处理message.java.lang.NullPointerException时发生的错误--C#错误只是由于服务器端NPE导致服务器过早关闭连接的结果。如果NPE是因为客户端发送了无效数据而发生的,那么生活就是这样。最好做好准备,因为客户会以奇怪的方式调用你的API。谢谢你的回答,我解决了这个问题。。我在数据库中有一行id=-1。。这就是为什么我有NullPointerException。
    18717 [main] ERROR org.apache.thrift.server.TSimpleServer - Error occurred during processing of message.
java.lang.NullPointerException
    at concurs.server.ConcursService$getCopii_result$getCopii_resultStandardScheme.write(ConcursService.java:4287)
    at concurs.server.ConcursService$getCopii_result$getCopii_resultStandardScheme.write(ConcursService.java:4226)
    at concurs.server.ConcursService$getCopii_result.write(ConcursService.java:4172)
    at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:55)
    at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
    at org.apache.thrift.server.TSimpleServer.serve(TSimpleServer.java:80)
    at concurs.StartObjectServer.main(StartObjectServer.java:20)
    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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
18717 [main] WARN org.apache.thrift.transport.TIOStreamTransport - Error closing output stream.
java.net.SocketException: Socket closed
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:116)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at java.io.FilterOutputStream.close(FilterOutputStream.java:158)
    at org.apache.thrift.transport.TIOStreamTransport.close(TIOStreamTransport.java:110)
    at org.apache.thrift.transport.TSocket.close(TSocket.java:235)
    at org.apache.thrift.server.TSimpleServer.serve(TSimpleServer.java:102)
    at concurs.StartObjectServer.main(StartObjectServer.java:20)
    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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)