gRPC client behaves differently when packaged with shadowJar

572 views
Skip to first unread message

Curtis Ullerich

unread,
Aug 12, 2022, 2:57:09 AM8/12/22
to grpc.io
This is a Kotlin gRPC project built with Gradle, packaged with the shadowJar plugin. Issuing an RPC succeeds when I use `./gradlew run`, and fails when I use `./gradlew runShadow` (which builds an uber-jar and runs it). 

It says "Exception in thread "main" io.grpc.StatusException: UNKNOWN" and "Caused by: java.nio.channels.UnsupportedAddressTypeException". The sample project and full stack trace are at https://github.com/curtisullerich/shadow-grpc

This is hopefully an issue with how I've configured my build, and I'm hoping that the error that gRPC throws can help point out the problem. The supposedly unsupported address type is simply "localhost". It makes me think that some runtime dependency must not be found. I checked the class files present in both cases and they were the same, but they appear in the classpaths in a different order. Fiddling with the ordering of the classpath entries yielded no discoveries.

Any ideas or pointers?

Thanks,
Curtis

Curtis Ullerich

unread,
Aug 14, 2022, 2:42:43 AM8/14/22
to grpc.io
The answer ended up being that the service descriptor files in gRPC's dependency jars clobbered each other during the merge. A friend pointed out that using shadowJar's mergeServiceFiles() feature fixed the problem:
tasks.named("shadowJar", ShadowJar::class) {
    mergeServiceFiles()
}
Reply all
Reply to author
Forward
0 new messages