The problem here is maven-assembly-plugin breaks SPI "services," because by
default it fails to combine some magic files together. This causes the dns
name resolver to not be found, and can prevent some transports and load
balancers also to not be found.

You need to configure it to use the metaInf-services handler. See
https://stackoverflow.com/a/49689041/4690866 (you can ignore the
metaInf-spring and plexus parts).

On Wed, May 22, 2024 at 9:03 AM 'Akash Sinha' via grpc.io <
grpc-io@googlegroups.com> wrote:

> Hello Everyone,
>
> I am trying to build a JAVA based gRPC client that tries to communicate
> with Python based gRPC server. I am getting the following exception when I
> run the code from terminal using the JAR file.
>
> Exception in thread "main"
> io.grpc.ManagedChannelRegistry$ProviderNotFoundException:
> io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider: does not support 1
> or more of [class
> io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress]
>
> at
> io.grpc.ManagedChannelRegistry.newChannelBuilder(ManagedChannelRegistry.java:204)
>
> at
> io.grpc.ManagedChannelRegistry.newChannelBuilder(ManagedChannelRegistry.java:155)
>
> at io.grpc.Grpc.newChannelBuilder(Grpc.java:101)
>
> The error happens while executing the following code:
> String target = "localhost:"+port;
>
> ManagedChannel channel = Grpc.newChannelBuilder(target,
> InsecureChannelCredentials.create()).build();
>
> However, the code runs fine when running the main class from the IDE. I
> have created the fat jar file using maven. Following is my pom.xml file.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd";>
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>org.example</groupId>
> <artifactId>DummyEnv</artifactId>
> <version>1.0-SNAPSHOT</version>
> <dependencies>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-netty-shaded</artifactId>
> <version>1.63.0</version>
> <scope>runtime</scope>
> </dependency>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-protobuf</artifactId>
> <version>1.63.0</version>
> </dependency>
> <dependency>
> <groupId>io.grpc</groupId>
> <artifactId>grpc-stub</artifactId>
> <version>1.63.0</version>
> </dependency>
> <dependency> <!-- necessary for Java 9+ -->
> <groupId>org.apache.tomcat</groupId>
> <artifactId>annotations-api</artifactId>
> <version>6.0.53</version>
> <scope>provided</scope>
> </dependency>
>
>
> </dependencies>
> <properties>
> <maven.compiler.source>21</maven.compiler.source>
> <maven.compiler.target>21</maven.compiler.target>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> </properties>
>
> <build>
> <extensions>
> <extension>
> <groupId>kr.motd.maven</groupId>
> <artifactId>os-maven-plugin</artifactId>
> <version>1.7.1</version>
> </extension>
> </extensions>
> <plugins>
> <plugin>
> <groupId>org.xolstice.maven.plugins</groupId>
> <artifactId>protobuf-maven-plugin</artifactId>
> <version>0.6.1</version>
> <configuration>
> <protocArtifact
> >com.google.protobuf:protoc:3.25.1:exe:${os.detected.classifier}</
> protocArtifact>
> <pluginId>grpc-java</pluginId>
> <pluginArtifact
> >io.grpc:protoc-gen-grpc-java:1.63.0:exe:${os.detected.classifier}</
> pluginArtifact>
> </configuration>
> <executions>
> <execution>
> <goals>
> <goal>compile</goal>
> <goal>compile-custom</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-assembly-plugin</artifactId>
> <version>3.7.1</version>
> <configuration>
> <descriptorRefs>
> <descriptorRef>jar-with-dependencies</descriptorRef>
> </descriptorRefs>
> </configuration>
> <executions>
> <execution>
> <id>assemble-all</id>
> <phase>package</phase>
> <goals>
> <goal>single</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </project>
>
> Can someone please help me in debugging this issue?
>
> Thanks :)
>
> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to grpc-io+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grpc-io/4ab9aa81-5fb5-4176-91eb-298ee6e55dbcn%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/4ab9aa81-5fb5-4176-91eb-298ee6e55dbcn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oOqWp-8UB9_Yq74CSst1tvaS%2BoqN1bDrjCrJWcY6qsC2w%40mail.gmail.com.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to