question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exceptions being thrown on execution with Spring related to gRPC and PerfMark

See original GitHub issue

Running Temporal with Spring generates some exceptions that are not thrown in a standalone Temporal instance.

// App.java 

@ComponentScan
@EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class})
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class, JHipsterExtraProperties.class})
public class App {
  public static void main(String[] args) {
    SpringApplication app = new SpringApplication(App.class);

    // some calls here ...

    // Init Temporal
    WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();
    WorkflowClient client = WorkflowClient.newInstance(service);
    WorkerFactory factory = WorkerFactory.newInstance(client);

    Worker worker = factory.newWorker("Queue1");
    worker.registerWorkflowImplementationTypes(HelloWorldImpl.class); // workflow calls the activity and returns the result
    worker.registerActivitiesImplementations(new SayHiActivityImpl()); // activity returns "Hello world"

    factory.start();

    HelloWorld workflow = client.newWorkflowStub(HelloWorld.class, WorkflowOptions.newBuilder().setTaskQueue("Queue1").build());

    System.out.println("Workflow result: " + workflow.sayHello()); // prints "Hello World"
  }
}

With this code, several exceptions are generated. However, they do not prevent the workflow and the activity from being correctly executed.


This next exceptions are thrown on line 84, which corresponds to the line WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();

2020-07-27 09:43:17.509 [main] DEBUG
        i.g.netty.shaded.io.grpc.netty.Utils - Epoll is not available, using Nio. 
java.lang.ExceptionInInitializerError: null
	at io.grpc.netty.shaded.io.netty.channel.epoll.Epoll.<clinit>(Epoll.java:39)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at io.grpc.netty.shaded.io.grpc.netty.Utils.isEpollAvailable(Utils.java:284)
	at io.grpc.netty.shaded.io.grpc.netty.Utils.<clinit>(Utils.java:107)
	at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.<clinit>(NettyChannelBuilder.java:74)
	at io.temporal.internal.grpc.WorkflowServiceStubsImpl.<init>(WorkflowServiceStubsImpl.java:108)
	at io.temporal.serviceclient.WorkflowServiceStubs.newInstance(WorkflowServiceStubs.java:34)
	at my.App.main(App.java:84)
Caused by: java.lang.IllegalStateException: Only supported on Linux
	at io.grpc.netty.shaded.io.netty.channel.epoll.Native.loadNativeLibrary(Native.java:225)
	at io.grpc.netty.shaded.io.netty.channel.epoll.Native.<clinit>(Native.java:58)
	... 9 common frames omitted
2020-07-27 09:43:17.603 [main] DEBUG
        i.g.i.AbstractManagedChannelImplBuilder - Unable to apply census stats 
java.lang.ClassNotFoundException: io.grpc.census.InternalCensusStatsAccessor
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at io.grpc.internal.AbstractManagedChannelImplBuilder.getEffectiveInterceptors(AbstractManagedChannelImplBuilder.java:534)
	at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:517)
	at io.temporal.internal.grpc.WorkflowServiceStubsImpl.<init>(WorkflowServiceStubsImpl.java:119)
	at io.temporal.serviceclient.WorkflowServiceStubs.newInstance(WorkflowServiceStubs.java:34)
	at my.App.main(App.java:84)
2020-07-27 09:43:17.603 [main] DEBUG
        i.g.i.AbstractManagedChannelImplBuilder - Unable to apply census stats 
java.lang.ClassNotFoundException: io.grpc.census.InternalCensusTracingAccessor
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at io.grpc.internal.AbstractManagedChannelImplBuilder.getEffectiveInterceptors(AbstractManagedChannelImplBuilder.java:569)
	at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:517)
	at io.temporal.internal.grpc.WorkflowServiceStubsImpl.<init>(WorkflowServiceStubsImpl.java:119)
	at io.temporal.serviceclient.WorkflowServiceStubs.newInstance(WorkflowServiceStubs.java:34)
	at my.App.main(App.java:84)

And this one is thrown after client.newWorkflowStub is called.

2020-07-27 09:43:17.992 [Activity Poller taskQueue="Queue1", namespace="default": 3] DEBUG
        io.perfmark.PerfMark - Error during PerfMark.<clinit> 
java.lang.ClassNotFoundException: io.perfmark.impl.SecretPerfMarkImpl$PerfMarkImpl
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at io.perfmark.PerfMark.<clinit>(PerfMark.java:36)
	at io.grpc.internal.ClientCallImpl.<init>(ClientCallImpl.java:109)
	at io.grpc.internal.ManagedChannelImpl$RealChannel.newCall(ManagedChannelImpl.java:890)
	at io.grpc.internal.ServiceConfigInterceptor.interceptCall(ServiceConfigInterceptor.java:137)
	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
	at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:855)
	at io.grpc.internal.ForwardingManagedChannel.newCall(ForwardingManagedChannel.java:63)
	at io.temporal.internal.grpc.GrpcMetricsInterceptor$MetricsClientCall.<init>(GrpcMetricsInterceptor.java:88)
	at io.temporal.internal.grpc.GrpcMetricsInterceptor.interceptCall(GrpcMetricsInterceptor.java:74)
	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
	at io.temporal.internal.grpc.GrpcDeadlineInterceptor.interceptCall(GrpcDeadlineInterceptor.java:69)
	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
	at io.grpc.stub.MetadataUtils$HeaderAttachingClientInterceptor.interceptCall(MetadataUtils.java:74)
	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:128)
	at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.pollActivityTaskQueue(WorkflowServiceGrpc.java:2682)
	at io.temporal.internal.worker.ActivityPollTask.poll(ActivityPollTask.java:95)
	at io.temporal.internal.worker.ActivityPollTask.poll(ActivityPollTask.java:38)
	at io.temporal.internal.worker.Poller$PollExecutionTask.run(Poller.java:273)
	at io.temporal.internal.worker.Poller$PollLoopTask.run(Poller.java:242)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
2020-07-27 09:43:18.009 [Activity Poller taskQueue="Queue1", namespace="default": 3] DEBUG
        io.grpc.Context - Storage override doesn't exist. Using default 
java.lang.ClassNotFoundException: io.grpc.override.ContextStorageOverride
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at io.grpc.Context$LazyStorage.createStorage(Context.java:142)
	at io.grpc.Context$LazyStorage.<clinit>(Context.java:131)
	at io.grpc.Context.storage(Context.java:119)
	at io.grpc.Context.current(Context.java:185)
	at io.grpc.internal.ClientCallImpl.<init>(ClientCallImpl.java:118)
	at io.grpc.internal.ManagedChannelImpl$RealChannel.newCall(ManagedChannelImpl.java:890)
	at io.grpc.internal.ServiceConfigInterceptor.interceptCall(ServiceConfigInterceptor.java:137)
	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
	at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:855)
	at io.grpc.internal.ForwardingManagedChannel.newCall(ForwardingManagedChannel.java:63)
	at io.temporal.internal.grpc.GrpcMetricsInterceptor$MetricsClientCall.<init>(GrpcMetricsInterceptor.java:88)
	at io.temporal.internal.grpc.GrpcMetricsInterceptor.interceptCall(GrpcMetricsInterceptor.java:74)
	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
	at io.temporal.internal.grpc.GrpcDeadlineInterceptor.interceptCall(GrpcDeadlineInterceptor.java:69)
	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
	at io.grpc.stub.MetadataUtils$HeaderAttachingClientInterceptor.interceptCall(MetadataUtils.java:74)
	at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:128)
	at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.pollActivityTaskQueue(WorkflowServiceGrpc.java:2682)
	at io.temporal.internal.worker.ActivityPollTask.poll(ActivityPollTask.java:95)
	at io.temporal.internal.worker.ActivityPollTask.poll(ActivityPollTask.java:38)
	at io.temporal.internal.worker.Poller$PollExecutionTask.run(Poller.java:273)
	at io.temporal.internal.worker.Poller$PollLoopTask.run(Poller.java:242)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Expected Behavior

Exceptions should not be thrown.

Actual Behavior

Exceptions are thrown for no apparent reason, since the same code in a standalone Temporal application doesn’t throw any exceptions.

Steps to Reproduce the Problem

  1. Use Temporal with a Spring app.
  2. Register a workflow.
  3. Execute it.

Specifications

  • Version: v0.2.7
  • Platform: Windows 10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Spikhalskiycommented, May 20, 2022

@J-DK It looks like the correct thing to do here. Temporal JavaSDK doesn’t use or need perfmark itself, so we are not going to add it as a transitive dependency.

1reaction
J-DKcommented, May 20, 2022
i.g.stub.ClientCalls$ThreadlessExecutor : Runnable threw exception
java.lang.NoClassDefFoundError: io/perfmark/PerfMark
at io.grpc.internal.ClientCallImpl.<init>(ClientCallImpl.java:106) ~[grpc-core-1.43.0.jar:1.43.0]

I faced the above issue and it is fixed by explicitly adding the below dependency in the build file implementation 'io.perfmark:perfmark-api:0.25.0'

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exceptions being thrown on execution with Spring related to ...
Running Temporal with Spring generates some exceptions that are not thrown in a standalone Temporal instance.
Read more >
Exception Handling inside GrpcService | grpc-spring-boot-starter
@GrpcAdvice marks a class to be checked up for exception handling methods ... method to be executed, in case of the specified exception...
Read more >
Java Binding: RunTime Exception, Uncaught exception in the ...
I was trying to access the Daml ledger from the Java maven service (MVC pattern). Whenever we hit the request from the postman...
Read more >
java.lang.NoClassDefFoundError: io/grpc/BindableService ...
It looks i have imported all needed dependencies. I also found out how one man fixed this issue with gradle: bindableService issue with...
Read more >
Open Source Used In Crosswork Data Gateway 1.1.4 - Cisco
1.210 perfmark-api 0.17.0. 1.210.1 Available under license. 1.211 apache-httpmime 4.2.3. 1.211.1 Available under license. 1.212 spring-boot-starter-tomcat ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found