Search code examples
mysqlmavengrpcgrpc-javaprotoc

Generated protoc file creates a target source with error


I have tried to make a project that connects to a DB and takes information and outputes them in a desktop application through grpc. But, when I compile it I get "Error:(20,18) java: cannot find symbol" in a target file( which is auto-generated by protoc. I can't understand the issue with this. I have tried to change the compiler of mvn, to change the version on protoc, to setup a different JDK, everything just gets worse that it already is.

My project can be viewed here : https://github.com/Diana-Ioana/grpc My db and error with the generated target files that crashes is : https://i.sstatic.net/7U1zB.jpg

I have no idea what to do now. Any help would be greate, thank you!


Solution

  • It looks like the "cannot find symbol" is referring to javax.annotation.Generated. In that case you can add a dependency on annotations-api:

        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>annotations-api</artifactId>
            <version>6.0.53</version>
            <!-- Generated has @Retention(SOURCE), so not needed at runtime -->
            <scope>provided</scope>
        </dependency>
    

    Originally this answer suggested javax.annotation-api, but that library is licensed CDDL so gRPC changed its recommendation.

        <!-- The old suggestion. Uses CDDL-licensed library -->
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.2</version>
        </dependency>