Closed smallufo closed 8 years ago
I think you're getting an older version of protobuf pulled in from somewhere. The missing method noted in the screenshot is present in v3.0.0. You can run mvn dependency:tree -Dverbose
to try to debug where the old copy may be coming from.
Hi , I check the dependencies , but found no error :
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: osx
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: osx-x86_64
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building destiny-identity 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ destiny-identity ---
[WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution
[INFO] artifact io.netty:netty-codec-http2: checking for updates from nexus
[INFO] artifact io.netty:netty-codec-http2: checking for updates from spring-snapshots
[INFO] artifact io.netty:netty-codec-http2: checking for updates from spring-milestones
[INFO] artifact io.netty:netty-codec-http2: checking for updates from central
[INFO] artifact io.grpc:grpc-core: checking for updates from nexus
[INFO] artifact io.grpc:grpc-core: checking for updates from spring-snapshots
[INFO] artifact io.grpc:grpc-core: checking for updates from spring-milestones
[INFO] artifact io.grpc:grpc-core: checking for updates from central
[INFO] destiny:destiny-identity:jar:0.0.1
[INFO] +- io.grpc:grpc-netty:jar:1.0.0:compile
[INFO] | +- io.netty:netty-codec-http2:jar:4.1.3.Final:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.3.Final:compile
[INFO] | | | \- io.netty:netty-codec:jar:4.1.3.Final:compile
[INFO] | | | \- (io.netty:netty-transport:jar:4.1.3.Final:compile - omitted for duplicate)
[INFO] | | \- io.netty:netty-handler:jar:4.1.3.Final:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.3.Final:compile
[INFO] | | | \- io.netty:netty-common:jar:4.1.3.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.3.Final:compile
[INFO] | | | +- (io.netty:netty-buffer:jar:4.1.3.Final:compile - omitted for duplicate)
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.3.Final:compile
[INFO] | | | \- (io.netty:netty-common:jar:4.1.3.Final:compile - omitted for duplicate)
[INFO] | | \- (io.netty:netty-codec:jar:4.1.3.Final:compile - omitted for duplicate)
[INFO] | \- io.grpc:grpc-core:jar:1.0.0:compile
[INFO] | +- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO] | \- com.google.code.findbugs:jsr305:jar:3.0.0:compile
[INFO] +- io.grpc:grpc-protobuf:jar:1.0.0:compile
[INFO] | +- com.google.guava:guava:jar:19.0:compile
[INFO] | +- io.grpc:grpc-protobuf-lite:jar:1.0.0:compile
[INFO] | | +- (com.google.guava:guava:jar:19.0:compile - omitted for duplicate)
[INFO] | | \- (io.grpc:grpc-core:jar:1.0.0:compile - omitted for duplicate)
[INFO] | +- com.google.protobuf:protobuf-java:jar:3.0.0:compile
[INFO] | +- com.google.protobuf:protobuf-java-util:jar:3.0.0:compile
[INFO] | | +- (com.google.protobuf:protobuf-java:jar:3.0.0:compile - omitted for duplicate)
[INFO] | | +- (com.google.guava:guava:jar:18.0:compile - omitted for conflict with 19.0)
[INFO] | | \- com.google.code.gson:gson:jar:2.7:compile (version managed from 2.3)
[INFO] | \- (io.grpc:grpc-core:jar:1.0.0:compile - omitted for duplicate)
[INFO] +- io.grpc:grpc-stub:jar:1.0.0:compile
[INFO] | \- (io.grpc:grpc-core:jar:1.0.0:compile - omitted for duplicate)
// skipped
It is com.google.protobuf:protobuf-java:jar:3.0.0:compile
, and there are no other protobuf
strings in the following skipped dependencies.
I pasted your proto into the grpc-java/examples/src/main/proto/echo_service.proto and it built without issue.
This log message looks interesting though:
[WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution
The Dependency Resolution of the compatibility notes provides a little bit of guidance, but not much.
I would still investigate dependency issues though, because InvalidProtocolBufferException did not have the IOException overload in 2.6.1.
Is there any fake
protobuf 3.0 on the internet ?
I remove the local repos:
smallufo@MacBookPro:~/.m2/repository/com/google $ rm -rf protobuf/
and re run mvn compile
$ mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: osx
[INFO] os.detected.arch: x86_64
[INFO] os.detected.classifier: osx-x86_64
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building destiny-identity 0.0.1
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.spring.io/snapshot/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.pom
Downloading: https://repo.spring.io/milestone/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.pom
Downloading: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.pom
Downloaded: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.pom (4 KB at 3.2 KB/sec)
Downloading: https://repo.spring.io/snapshot/com/google/protobuf/protobuf-parent/3.0.0/protobuf-parent-3.0.0.pom
Downloading: https://repo.spring.io/milestone/com/google/protobuf/protobuf-parent/3.0.0/protobuf-parent-3.0.0.pom
Downloading: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-parent/3.0.0/protobuf-parent-3.0.0.pom
Downloaded: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-parent/3.0.0/protobuf-parent-3.0.0.pom (7 KB at 9.9 KB/sec)
Downloading: https://repo.spring.io/snapshot/com/google/protobuf/protobuf-java-util/3.0.0/protobuf-java-util-3.0.0.pom
Downloading: https://repo.spring.io/milestone/com/google/protobuf/protobuf-java-util/3.0.0/protobuf-java-util-3.0.0.pom
Downloading: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java-util/3.0.0/protobuf-java-util-3.0.0.pom
Downloaded: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java-util/3.0.0/protobuf-java-util-3.0.0.pom (4 KB at 5.6 KB/sec)
Downloading: https://repo.spring.io/snapshot/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar
Downloading: https://repo.spring.io/snapshot/com/google/protobuf/protobuf-java-util/3.0.0/protobuf-java-util-3.0.0.jar
Downloading: https://repo.spring.io/milestone/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar
Downloading: https://repo.spring.io/milestone/com/google/protobuf/protobuf-java-util/3.0.0/protobuf-java-util-3.0.0.jar
Downloading: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar
Downloading: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java-util/3.0.0/protobuf-java-util-3.0.0.jar
Downloaded: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java-util/3.0.0/protobuf-java-util-3.0.0.jar (64 KB at 59.2 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar (1274 KB at 897.7 KB/sec)
[INFO]
[INFO] --- protobuf-maven-plugin:0.5.0:compile (default) @ destiny-identity ---
Downloading: https://repo.spring.io/snapshot/com/google/protobuf/protoc/3.0.0/protoc-3.0.0.pom
Downloading: https://repo.spring.io/milestone/com/google/protobuf/protoc/3.0.0/protoc-3.0.0.pom
Downloading: https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0.pom
Downloaded: https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0.pom (5 KB at 10.1 KB/sec)
Downloading: https://repo.spring.io/snapshot/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-osx-x86_64.exe
Downloading: https://repo.spring.io/milestone/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-osx-x86_64.exe
Downloading: https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-osx-x86_64.exe
Downloaded: https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-osx-x86_64.exe (4698 KB at 3847.3 KB/sec)
[INFO] Compiling 1 proto file(s) to /Users/smallufo/Dropbox/destiny/destiny-identity/target/generated-sources/protobuf/java
[INFO]
[INFO] --- protobuf-maven-plugin:0.5.0:compile-custom (default) @ destiny-identity ---
[INFO] Compiling 1 proto file(s) to /Users/smallufo/Dropbox/destiny/destiny-identity/target/generated-sources/protobuf/grpc-java
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ destiny-identity ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] Copying 3 resources
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ destiny-identity ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 83 source files to /Users/smallufo/Dropbox/destiny/destiny-identity/target/classes
[INFO] /Users/smallufo/Dropbox/destiny/destiny-identity/src/main/java/destiny/tools/CookieTools.java: Some input files use unchecked or unsafe operations.
[INFO] /Users/smallufo/Dropbox/destiny/destiny-identity/src/main/java/destiny/tools/CookieTools.java: Recompile with -Xlint:unchecked for details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.604 s
[INFO] Finished at: 2016-09-27T02:18:28+08:00
[INFO] Final Memory: 37M/342M
[INFO] ------------------------------------------------------------------------
But it still generates incompatible EchoServiceOuterClass.java
This is the generated code , FYI
I'm not aware of any fake protobuf 3, but it looks like something strange may be going on.
But it still generates incompatible EchoServiceOuterClass.java
What do you mean? It looks like it worked.
The generated EchoServiceOuterClass.java still cannot be compiled because of incompatibilities:
I decide to create another clean project , and compile again. It seems OK now .
It is very weird. See below :
The front is window is the new(clean) test project . The generated EchoServiceOuterClass.java
is Ok , and the dependent jar InvalidProtocolBufferException
has IOException constructor.
But the old version included jar only has String constructor.
The two jars are the same !!! Without source , but IntelliJ decompile one with bytecode version 50.0 , but another id version 49.0 !!?
I try to Reveal in Finder
, both protobuf-java-3.0.0.jar
are locating in ~/.m2/repository/com/google/protobuf/protobuf-java/3.0.0/protobuf-java-3.0.0.jar
. It's ONE file, not two different jar.
I am really puzzled...
Wat? Yeah, that's strange. The one on my machine is bytecode version 50. I've also confirmed there isn't a duplicate class in the JAR (which is possible with zips). I'd also still believe that the IDE was accidentally showing you a different protobuf version.
But in either case, it seems you're working now.
OK . I found where goes wrong.
TIL libphonenumber
also dependent on protobuf !
And the project is dependent on an older libphonenumber
, not via maven , it is via groovy's @Grab
!.
That's why mvn's dependency:tree cannot inspect the problem !
And maybe intelliJ regard groovy's @Grab
has higher priority.
Anyway , it is fixed. sorry for disturb.
I am experiencing similar issues. Generated code has lots of errors in Outer cass, main class looks ok. I've attached sample project. GRPC connector is here... https://github.com/mulesoft-labs/grpc-connector
Hi , I am new to gRPC / protobuf , and facing a first step problem...
This is my first .proto file :
It is simple , but the generated EchoServiceOuterClass.java has a lot of incompatibilities :
For example :
This is my [ partial ] pom.xml
The grpc-netty , grpc-protobuf , grpc-stub are all of version of 1.0.0
Where goes wrong here ?
Thanks.
I am new to gRPC / protobuf , sorry I don't know whether the problem is related to grpc-java project or not.