gatling-grpc icon indicating copy to clipboard operation
gatling-grpc copied to clipboard

java.lang.NoClassDefFoundError with latest grpc plugin

Open bcarter97 opened this issue 1 year ago • 0 comments

Describe the bug

In scalapb-runtime 0.11.15 we are seeing the following error:

[error] Test suite failed with java.lang.NoClassDefFoundError: io/grpc/internal/AbstractManagedChannelImplBuilder.
[error] This may be due to the ClassLoaderLayeringStrategy (ScalaLibrary) used by your task.
[error] To improve performance and reduce memory, sbt attempts to cache the class loaders used to load the project dependencies.
[error] The project class files are loaded in a separate class loader that is created for each test run.
[error] The test class loader accesses the project dependency classes using the cached project dependency classloader.
[error] With this approach, class loading may fail under the following conditions:
[error] 
[error]  * Dependencies use reflection to access classes in your project's classpath.
[error]    Java serialization/deserialization may cause this.
[error]  * An open package is accessed across layers. If the project's classes access or extend
[error]    jvm package private classes defined in a project dependency, it may cause an IllegalAccessError
[error]    because the jvm enforces package private at the classloader level.
[error] 
[error] These issues, along with others that were not enumerated above, may be resolved by changing the class loader layering strategy.
[error] The Flat and ScalaLibrary strategies bundle the full project classpath in the same class loader.
[error] To use one of these strategies, set the  ClassLoaderLayeringStrategy key
[error] in your configuration, for example:
[error] 
[error] set classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.ScalaLibrary
[error] set classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
[error] 
[error] See ClassLoaderLayeringStrategy.scala for the full list of options.

To Reproduce

use gatling-grpc with a newer version of sbt-protoc compilerplugin

Other context

AbstractManagedChannelImplBuilder was removed in grpc-java 1.59.0 - https://github.com/grpc/grpc-java/releases/tag/v1.59.0

This was updated in scalapb in https://github.com/scalapb/ScalaPB/pull/1598 which scalapb-runtime uses

Is this just a case of updating the compilerplugin to the latest?

https://github.com/phiSgr/gatling-grpc/blob/a56d9de763165a0a073649ee8fb3dc8ef80001c7/project/scalapb.sbt#L3

Additionally I can see sbt-protoc has an update for 1.0.7, would it make sense to update that too?

https://github.com/phiSgr/gatling-grpc/blob/a56d9de763165a0a073649ee8fb3dc8ef80001c7/project/scalapb.sbt#L1

bcarter97 avatar Jan 26 '24 11:01 bcarter97