1

My group is trying to build a server using Apache Thrift but we are having strange compilation issues. In the generated Java files from Thrift, the following lines are present:

  public static class Client extends shared.BasicServer.Client implements org.apache.thrift.TServiceClient, Iface {
  public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {

These are defined as inner classes. When I try to build the project in Eclipse, it actually creates the .class files and the program runs, but Eclipse still says there are various errors related to these lines, including the following:

Bound mismatch: The type Backend.Client is not a valid substitute for the bounded parameter of the type TServiceClientFactory Backend.java /server/src/thrift line 42 Java Problem

The type TServiceClient cannot be a superinterface of Client; a superinterface must be an interface Backend.java /server/src/thrift line 41 Java Problem

I believe this is because org.apache.thrift.TServiceClient is actually an abstract class, not an interface, and yet Client is trying to implement it. However, as I said before, the program compiles and works, and I don't really understand how.

Does anyone have any idea how to get rid of/suppress these errors? I have a feeling there is some simple option I should be passing to my build configuration.

2 Answers 2

4

I ran into this same issue In Eclipse, as well as IntelliJ.

What I found was that thrift versions between the thrift compiler and lib-thrift were not in sync.

I had version 0.6.0 of thrift (from $sudo port install thrift) that i used to generate my java code, and was using lib-thrift-0.8.0.jar

I followed the following instructions to install Thrift from source, for my platform, and then regenerated and updated my java generated thrift code and these errors were resolved.

Sign up to request clarification or add additional context in comments.

Comments

1

maven generated:

<dependency>
    <groupId>org.apache.thrift</groupId>
    <artifactId>libthrift</artifactId>
    <version>0.8.0</version>
    <type>pom</type>
</dependency>

Just delete the element: type, then rebuild it.

<dependency>
    <groupId>org.apache.thrift</groupId>
    <artifactId>libthrift</artifactId>
    <version>0.8.0</version>
</dependency>

1 Comment

thrift 0.10.0, <groupId>org.apache.thrift</groupId><artifactId>libthrift</artifactId<version>0.10.0</version>, <groupId>org.apache.thrift</groupId><artifactId>thrift-maven-plugin</artifactId<version>0.10.0</version> Java 1.8, works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.