How to resolve java.lang.NoClassDefFoundError: io/grpc/BindableService

Experts,
I am new to temporal and exploring its basic,I tried running the basic java but getting the following exception "java.lang.NoClassDefFoundError: io/grpc/BindableService ".

Temporal Version: 28 and is up and running

Following are the jars used

  1. commons-configuration2-2.7.jar
  2. grpc-stub-1.31.0.jar
  3. logback-classic-1.2.3.jar
  4. protobuf-java-2.0.1.jar
  5. slf4j-api-1.7.30.jar
  6. temporal-sdk-0.28.0.jar

Sample Java:
Referred https://docs.temporal.io/docs/java-quick-start/ GettingStarted progm.
Exception: When i try to run this from my Eclipse it gives following exception
Exception in thread “main” java.lang.NoClassDefFoundError: io/grpc/BindableService
at io.temporal.serviceclient.WorkflowServiceStubs.newInstance(WorkflowServiceStubs.java:34)
at com.sci.sample.helloWorld.GettingStarted.main(GettingStarted.java:37)
Caused by: java.lang.ClassNotFoundException: io.grpc.BindableService

Sample Java:
package com.sci.sample.helloWorld;

import org.slf4j.Logger;

import io.temporal.client.WorkflowClient;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.worker.Worker;
import io.temporal.worker.WorkerFactory;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;

public class GettingStarted {

//private static Logger logger = Workflow.getLogger(GettingStarted.class);

@WorkflowInterface
public interface HelloWorld {

	@WorkflowMethod
	void sayHello(String name);
}

public static class HelloWorldImpl implements HelloWorld {

	@Override
	public void sayHello(String name) {
		System.out.println("Hello " + name + "!");
	}

}

public static void main(String[] args) {
	try {
		System.out.println("--STARTING--");
		// gRPC stubs wrapper that talks to the local docker instance of temporal service.
		WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();
		// client that can be used to start and signal workflows
		WorkflowClient client = WorkflowClient.newInstance(service);
		// worker factory that can be used to create workers for specific task queues
		WorkerFactory factory = WorkerFactory.newInstance(client);
		Worker worker = factory.newWorker("HelloWorldTaskQueue");
		worker.registerWorkflowImplementationTypes(HelloWorldImpl.class);
		factory.start();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}

}

1 Like

how did you set up the project , downloading the samples and importing as a gradle project worked for me, it brought all the dependencies.

However i tried with 0.23.0, but i don’t think it should be any different in 0.28.0.

1 Like

Thanks Madhu,

Initially i took the v28 > imported it on my STS > did the build. Build was successful but while running from STS i was getting this exception.

Now i build the the project > imported on my STS. In this case i am able to successfully run the app.

2 Likes