2012-09-20 79 views
1

我正在試驗一個簡單的Thrift服務器,並希望用java編寫客戶端。 我跑的命令生成的Java代碼編譯錯誤Thrift 0.8.0

- >節儉-gen的java BLT.thrift

生成的Java文件Optimization.java示出了在Eclipse IDE下面的錯誤。

public static class Client extends org.apache.thrift.TServiceClient implements Iface 

Error: The type TServiceClient cannot be the superclass of Client; asuperclass must be a class

public Client(org.apache.thrift.protocol.TProtocol prot) 
{ 
    super(prot, prot); 
} 

The constructor Object(TProtocol, TProtocol) is undefined. .....

我還是繼續和它編譯。

->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

我也沒有用於生成代碼,並且得到了使用上述拉罐罐子的校驗POM。有人會知道爲什麼這些會有所不同

->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

我在我的pom.xml 以下依賴我在我的pom.xml以下依賴性 org.apache.thrift libthrift 0.8.0 user1686831

回答

1

你好像有錯libthrift版本鏈接:和

public abstract class TServiceClient 

在0.6.1: org.apache.thrift.TServiceClient被定義爲0.8.0如下

public interface TServiceClient 

我建議檢查您的項目中是否存在舊libthrift jar中的傳遞依賴項。

+0

感謝指出這一點。事實證明,我的pom.xml引用了造成這些問題的hadoop jar。令人驚訝的是做mvn依賴的事實:tree | grep -i thrift只顯示org.apache.thrift:libthrift:jar:0.8.0:compile。看起來hadoop包裝了節儉瓶,而不是將其作爲依賴項。 – user1686831

+0

注意版本+1。即使我有0.8和0.9的問題。某些方法簽名已更改。請注意Thrift編譯器版本和libthrift jar版本匹配。 – TechSpellBound