Activity Method threw 'java.lang.IllegalArgumentException' exception. Cannot evaluate com.sun.proxy.$Proxy53.toString()

I’m creating activity object with the below code:

private final RetryOptions retryoptions = RetryOptions.newBuilder().setInitialInterval(Duration.ofSeconds(1))
            .setMaximumInterval(Duration.ofSeconds(100)).setBackoffCoefficient(2).setMaximumAttempts(50000).build();

private final ActivityOptions options = ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(30000))
            .setRetryOptions(retryoptions).build();

private final OrderActivities activity = Workflow.newActivityStub(OrderActivities.class, options);

private final RuleActivities ruleActivities = Workflow.newActivityStub(RuleActivities.class, options);

But, when I start up the application, I get the error:
Method threw 'java.lang.IllegalArgumentException' exception. Cannot evaluate com.sun.proxy.$Proxy53.toString()

I have already defined the bean implementations in a config file:

@Bean
public OrderActivitiesImpl SignUpActivity() {
        return new OrderActivitiesImpl();
}


@Bean
public RuleActivitiesImpl ruleActivity() {
        return new RuleActivitiesImpl();
}

Also, I have registered the activities in the starter:

@SpringBootApplication
public class ServiceApplication {

	public static void main(String[] args) {

		ConfigurableApplicationContext appContext = SpringApplication.run(ServiceApplication.class, args);
		WorkerFactory factory = appContext.getBean(WorkerFactory.class);
		OrderActivities orderActivity = appContext.getBean(OrderActivities.class);
		RuleActivities ruleActivities = appContext.getBean(RuleActivities.class);
		Worker worker = factory.newWorker(OrderWorkflow.QUEUE_NAME);
		worker.registerWorkflowImplementationTypes(OrderWorkflowImpl.class);
		worker.registerActivitiesImplementations(orderActivity,ruleActivities);
		factory.start();
	}

OrderActivities interface →

@ActivityInterface
public interface OrderActivities {

    @ActivityMethod
    void placeOrder();

    @ActivityMethod
    void setOrderAccepted();

    @ActivityMethod
    void setOrderPickedUp();

    @ActivityMethod
    void setOrderDelivered();
}

RuleActivities interface →

@ActivityInterface
public interface RuleActivities {

    @ActivityMethod
    Map<String, Map<String, Object>> fetchBusinessRules(Map<String,Object> input);

}

I’m not sure what is going wrong here as the error traces are not intuitive. The only hint available is that the error is thrown at Workflow.newActivityStub() . Any tips would be highly appreciated. Thanks!

Do you get same error if you register a new instance of your activity impls with worker rather than getting them from appContext.getBean?
For example:


worker.registerActivitiesImplementations(new OrderActivitiesImpl(), new RuleActivitiesImpl());

Also check out spring boot autoconfig support in java sdk: sdk-java/temporal-spring-boot-autoconfigure-alpha at master · temporalio/sdk-java · GitHub
Demo: GitHub - tsurdilo/temporal-springboot-demo

No, it didnt help.
Also, while debugging, I see that it gets into the activity method after multiple retries.

Then, I removed the retry options for debugging:


private final ActivityOptions options = ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(30000))
            .setRetryOptions(null).build();

and all of a sudden everything worked perfectly!

This was the retry options object:

private final RetryOptions retryoptions = RetryOptions.newBuilder().setInitialInterval(Duration.ofSeconds(1))
            .setMaximumInterval(Duration.ofSeconds(100)).setBackoffCoefficient(2).setMaximumAttempts(50000).build();

any idea what was going wrong?

Note that the activity method fetchBusinessRules() is a time consuming operation (around 1-2 seconds)

Not sure about the original problem. But the start to close timeout of 30k seconds without heartbeat timeout looks dangerous. Do you realize that in case of a worker failure, the activity will not be retried for 30k seconds?

As far as the original problem. Would you post the complete stack trace of the error?

yup, that was modified for testing, while the actual value was 30 seconds.

I put back actual retry options instead of null and still working good!
I was able to reproduce the error only when I put debug points around the activity/wokflow methods!!
No issues if I run the application as it is. Issue is only when we debug the application :slightly_smiling_face:

Here is the error:

As I understand, IDE tries to print a variable that has a bug in toString. Thanks a lot for reporting. I’ve filed an issue to get this fixed.