Getting java.lang.NoClassDefFoundError for class io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder

909 Views Asked by At

I am running a jar on spark slave with version spark-2.5.6-bin-hadoop where i am getting this error on submitting the jar

Exception occurred while create new JwtSource
java.lang.NoClassDefFoundError: Could not initialize class io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder
    at io.spiffe.workloadapi.internal.GrpcManagedChannelFactory.createNativeSocketChannel(GrpcManagedChannelFactory.java:55)
    at io.spiffe.workloadapi.internal.GrpcManagedChannelFactory.newChannel(GrpcManagedChannelFactory.java:41)
    at io.spiffe.workloadapi.DefaultWorkloadApiClient.newClient(DefaultWorkloadApiClient.java:133)
    at io.spiffe.workloadapi.DefaultJwtSource.createClient(DefaultJwtSource.java:221)
    at io.spiffe.workloadapi.DefaultJwtSource.newSource(DefaultJwtSource.java:90)

The spiffe dependency i am using is this

{
    "bagAttributes":
    {
        "entityId": "e51810ec.0372.2342.8d1e.140a06aad6baWCmFcmhRHh",
        "created": 1627654402157,
        "updated": 1694592585758,
        "version": 1,
        "elements":
        {
            "U.S. Polo Assn.##Casual Shoes##Men":
            {
                "created": 1694527195590,
                "updated": 1694527195590,
                "lastPrice": 1799.0,
                "lastPriceTs": 1694527178000,
                "latestStyleId": "10339033",
                "viewCount": 1,
                "latestEventTs": 1694527178000
            }
        }
    }
}

From whatever solution i could find online , it seemed the issue is from guava version where the jar i am deploying is build from guava 29.0-jre while spark slave is picking the guava-14.0jar from /opt/spark-2.4.6-bin-hadoop2.7/jars

please show me how to resolve these dependency conflict issues.

1

There are 1 best solutions below

1
Edwin Buck On

The general approach is to take the older library and update it, possibly updating any of the other items that required the older library to the newer versions that require the newer library.

In your case, you should probably update spark, guava, and possibly a bit more.