Maven & Protobuf compile error: Cannot find symbol in package com.google.protobuf

I had the same problem. building the protobuf sources from google directly (I used 2.5.0) and doing

mvn install:install-file -Dpackaging=jar -DgeneratePom=true  -DgroupId=com.google.protobuf   -DartifactId=protobuf-java   -Dfile=protobuf-java-2.5.0.jar -Dversion=2.5.0

fixed the problem for me.

In my earlier trials I noticed, that the jar-file in /root/.m2/repository/com/google/protobuf/protobuf-java/2.5.0/ was missing.

Maybe try to use version 2.5.0 in the pom.xml and/or copying the jarfile manually.

cheers


I had this problem when there was a mismatch between the protoc version installed and the version listed in the pom. Matching the versions fixed the problem. In my case, I had to switch my protoc version back to 2.4.1 to match the POM.


The protoc --version has to be the same version to as set in pom.xml file (protobuf-java-2.5.0.jar).