我正在试验一个简单的Thrift服务器,并希望用java编写客户端。 我运行了命令
- > thrift -gen java BLT.thrift
生成的java文件Optimization.java在Eclipse IDE中显示以下错误。
public static class Client extends org.apache.thrift.TServiceClient implements Iface
错误:TServiceClient类型不能是Client的超类; asuperclass必须是一个类
public Client(org.apache.thrift.protocol.TProtocol prot)
{
super(prot, prot);
}
构造函数Object(TProtocol,TProtocol)未定义。 .....
我仍然继续编译它。
->mvn clean install
Optimization.java:[38,54] no interface expected here
[ERROR] /thrift/Optimization.java:[39,83] type parameter model.thrift.Optimization.Client is not within its bound
[ERROR] /thrift/Optimization.java:[68,6] cannot find symbol
symbol : method
sendBase(java.lang.String,com.model.thrift.Optimization.maximizeRevenue_args)
location: class model.thrift.Optimization.Client
[ERROR] /thrift/Optimization.java:[74,6] cannot find symbol
symbol : method
receiveBase(model.thrift.Optimization.maximizeRevenue_result,java.lang.String)
location: class model.thrift.Optimization.Client
[ERROR] /thrift/Optimization.java:[98,97] cannot find symbol
symbol : variable ___protocolFactory
location: model.thrift.Optimization.AsyncClient
[ERROR] /thrift/Optimization.java:[98,117] cannot find symbol
symbol : variable ___transport
location: class model.thrift.Optimization.AsyncClient
[ERROR] /thrift/Optimization.java:[99,10] cannot find symbol
symbol : variable ___currentMethod
location: class model.thrift.Optimization.AsyncClient
[ERROR] /thrift/Optimization.java:[100,6] cannot find symbol
symbol : variable ___manager
location: class thrift.Optimization.AsyncClient
[ERROR] /thrift/Optimization.java:[387,23] cannot find symbol
symbol : method getScheme()
location: class org.apache.thrift.protocol.TProtocol
[ERROR] /thrift/Optimization.java:[391,23] cannot find symbol
symbol : method getScheme()
location: class org.apache.thrift.protocol.TProtocol
[ERROR] /thrift/Optimization.java:[665,23] cannot find symbol
symbol : method getScheme()
location: class org.apache.thrift.protocol.TProtocol
[ERROR] /thrift/Optimization.java:[669,23] cannot find symbol
symbol : method getScheme()
-> mvn dependency:tree | grep -i thrift
[INFO] \- org.apache.thrift:libthrift:jar:0.8.0:compile
-> thrift -version java
Thrift version 0.8.0
我找到了这个帖子,但推荐的解决方案对我不起作用 Maven Thrift repository
我还做了一个用于生成代码的jar的校验和以及使用上面的pom拉出的jar。有人会知道为什么这些会有所不同
->md5sum /usr/local/lib/libthrift-0.8.0.jar
fff7102558cb0ab1c103b62752166ce8 /usr/local/lib/libthrift-0.8.0.jar
->md5sum ~/.m2/repository/org/apache/thrift/libthrift/0.8.0/libthrift-0.8.0.jar
d68695bb2406cb2ab5fbae6ff6e27d7e
/home/nipun/.m2/repository/org/apache/thrift/libthrift/0.8.0/libthrift-0.8.0.jar
非常感谢任何帮助/见解。
答案 0 :(得分:1)
看起来你正在使用错误的libthrift版本链接: org.apache.thrift.TServiceClient在0.8.0中定义如下:
public abstract class TServiceClient
和0.6.1:
public interface TServiceClient
我建议在旧的libthrift jar上检查项目中是否存在传递依赖项。