grpc-core and grpc-context jars exporting the same package doesnt go well with OSGI
See original GitHub issuePlease answer these questions before submitting your issue.
What version of gRPC are you using?
GRPC version 1.1.2
What JVM are you using (java -version
)?
1.8
What did you do?
I am trying to add a GRPC Server into Karaf OSGI Container as a feature. To this library, grpc-core and grpc-context libraries are dependencies.
Because these jars are not OSGI bundles, the osgi wrap is performed. While running the application, we get an error that io.grpc.Context could not be found in bundle grpc-core.jar (NoClassDefFoundError)
For information please refer to the OSGI bundle definitions.
karaf@root()> la |grep -i grpc-core 83 | Active | 80 | 0 | wrap_file__home_apache-karaf-4.0.8_data_kar_mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT_io_grpc_grpc-core_1.1.2_grpc-core-1.1.2.jar
karaf@root()> bundle:headers 83
wrap_file__home_apache-karaf-4.0.8_data_kar_mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT_io_grpc_grpc-core_1.1.2_grpc-core-1.1.2.jar (83)
Bnd-LastModified = 1486762343975 Built-By = root Built-JDK = 1.8.0_45 Created-By = 1.8.0_121 (Oracle Corporation) Generated-By-Ops4j-Pax-From = wrap:file:/home/apache-karaf-4.0.8/data/kar/mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT/io/grpc/grpc-core/1.1.2/grpc-core-1.1.2.jar Implementation-Title = grpc-core Implementation-Version = 1.1.2 Manifest-Version = 1.0 Source-Compatibility = 1.6 Target-Compatibility = 1.6 Tool = Bnd-2.3.0.201405100607
Bundle-ManifestVersion = 2 Bundle-Name = wrap_file__home_apache-karaf-4.0.8_data_kar_mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT_io_grpc_grpc-core_1.1.2_grpc-core-1.1.2.jar Bundle-SymbolicName = wrap_file__home_apache-karaf-4.0.8_data_kar_mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT_io_grpc_grpc-core_1.1.2_grpc-core-1.1.2.jar Bundle-Version = 0 Require-Capability = osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=1.6))
Export-Package = io.grpc;uses:=“com.google.common.base,com.google.errorprone.annotations,javax.annotation,javax.net.ssl”, io.grpc.inprocess;uses:=“com.google.instrumentation.stats,io.grpc,io.grpc.internal”, io.grpc.internal;uses:=“com.google.common.base,com.google.instrumentation.stats, io.grpc,javax.annotation”, io.grpc.util;uses:=“io.grpc,javax.annotation” Import-Package = com.google.common.base;resolution:=optional, com.google.common.io;resolution:=optional, com.google.common.util.concurrent;resolution:=optional, com.google.errorprone.annotations;resolution:=optional, com.google.instrumentation.stats;resolution:=optional, javax.annotation;resolution:=optional, javax.net.ssl;resolution:=optional
karaf@root()> la |grep -i grpc-context 82 | Active | 80 | 0 | wrap_file__home_apache-karaf-4.0.8_data_kar_mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT_io_grpc_grpc-context_1.1.2_grpc-context-1.1.2.jar
karaf@root()> bundle:headers 82
wrap_file__home_apache-karaf-4.0.8_data_kar_mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT_io_grpc_grpc-context_1.1.2_grpc-context-1.1.2.jar (82)
Bnd-LastModified = 1486762343849 Built-By = root Built-JDK = 1.8.0_45 Created-By = 1.8.0_121 (Oracle Corporation) Generated-By-Ops4j-Pax-From = wrap:file:/home/apache-karaf-4.0.8/data/kar/mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT/io/grpc/grpc-context/1.1.2/grpc-context-1.1.2.jar Implementation-Title = grpc-context Implementation-Version = 1.1.2 Manifest-Version = 1.0 Source-Compatibility = 1.6 Target-Compatibility = 1.6 Tool = Bnd-2.3.0.201405100607
Bundle-ManifestVersion = 2 Bundle-Name = wrap_file__home_apache-karaf-4.0.8_data_kar_mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT_io_grpc_grpc-context_1.1.2_grpc-context-1.1.2.jar Bundle-SymbolicName = wrap_file__home_apache-karaf-4.0.8_data_kar_mvm-core-grpcapi-17.6.0-rel.3-SNAPSHOT_io_grpc_grpc-context_1.1.2_grpc-context-1.1.2.jar Bundle-Version = 0
Require-Capability = osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=1.6))
Export-Package = io.grpc
As you can notice, the problem seems to be because of the same export-packages defined in grpc-core and grpc-context which doesnt seem to go well with OSGI.
I reverted my GRPC version to 1.0.0 in which the jars were broken down to core and context and it worked well.
So the requests are as below:
a) A single jar which includes both core and context b) If context is intended to be separate, i suggest different packages be used in context so that there wont be a collision on the export-packages.
Is there a plan to create a OSGI bundle for these jars?
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (4 by maintainers)
Top GitHub Comments
Note: the generated code also can run afoul of Java 9 modules. If nothing else, the gRPC generated code is frequently in a separate JAR from the protobuf generated code, but the two exist in the same package.
I also faced the same problem when deploying gRPC in karaf container. At present I have a solution as follows: