Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No functional channel service provider found after shading io.grpc #3141

Closed
jingliucsd opened this issue Jun 27, 2017 · 3 comments
Closed

No functional channel service provider found after shading io.grpc #3141

jingliucsd opened this issue Jun 27, 2017 · 3 comments

Comments

@jingliucsd
Copy link

jingliucsd commented Jun 27, 2017

Please answer these questions before submitting your issue.

What version of gRPC are you using?

1.4

What JVM are you using (java -version)?

1.8

What did you do?

I have a code base that relies on Guava 14.0 and I would also like to use gRPC in my project.
gRPC needs Guava 19.0, which is not compatible with Guava 14.0.

Following some instructions online (https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html), I tried to shade/relocate gRPC library using the following pom.xml file.

I manually rename affected classed in the files that protobuf generates. The project builds fine, but when I ran it, I got the following error msg:

com.shade.io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional channel service provider found. Try adding a dependency on the grpc-okhttp or grpc-netty artifact

As shown in the pom.xml, those dependencies have been added.

If possible, provide a recipe for reproducing the error.

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shade</groupId>
    <artifactId>shade_grpc</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-okhttp</artifactId>
            <version>1.4.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations>
                                <relocation>
                                    <pattern>com.google.common</pattern>
                                    <shadedPattern>com.shade.google.common</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>io.grpc</pattern>
                                    <shadedPattern>com.shade.io.grpc</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>io.netty</pattern>
                                    <shadedPattern>com.shade.io.netty</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

What did you expect to see?

expect it to run without exceptions

What did you see instead?

The project builds fine, but when I ran it, I got the following error msg:

com.shade.io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional channel service provider found. Try adding a dependency on the grpc-okhttp or grpc-netty artifact

As shown in the pom.xml, those dependencies have been added.

@carl-mastrangelo
Copy link
Contributor

@jingliucsd can you run unzip -l output.jar on the file you generated? There should be a META-INF/services directory which links to the service loader files.

@ejona86
Copy link
Member

ejona86 commented Jun 28, 2017

It's a bug in the maven-shade-plugin. Upgrade to 3.0 and enable the ServicesResourceTransformer.

@jingliucsd
Copy link
Author

@ejona86 really appreciate your help! It works now.

And I also want to share some unsuccessful efforts I made, just in case someone encountered similar issues in the future.

Merely shading com.google.com may not work. It can solve the "No functional channel service provider found" issue but my program somehow hangs. Seems like some deadlocking issue.

@lock lock bot locked and limited conversation to collaborators Sep 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants