Netflix / conductor

Conductor is a microservices orchestration engine.
Apache License 2.0
12.82k stars 2.34k forks source link

java.lang.LinkageError with Spring boot 3.1.x #3645

Open exelon-admin opened 1 year ago

exelon-admin commented 1 year ago

Hello,

I am having an issue starting up my Spring boot 3 application with netflix conductor. Getting the following exceptions on startup.

...Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.conductor.client.http.WorkflowClient]: Factory method 'getWorkflowClient' threw exception with message: ClassCastException: attempting to castjar:file:/Users/user/.gradle/caches/modules-2/files-2.1/javax.ws.rs/javax.ws.rs-api/2.1.1/d3466bc9321fe84f268a1adb3b90373fc14b0eb5/javax.ws.rs-api-2.1.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/javax.ws.rs/javax.ws.rs-api/2.1.1/d3466bc9321fe84f268a1adb3b90373fc14b0eb5/javax.ws.rs-api-2.1.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:171) ~[spring-beans-6.0.9.jar:6.0.9] SimpleInstantiationStrategy.java:171 at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-6.0.9.jar:6.0.9] ConstructorResolver.java:655 ... 124 common frames omitted Caused by: java.lang.LinkageError: ClassCastException: attempting to castjar:file:/Users/user/.gradle/caches/modules-2/files-2.1/javax.ws.rs/javax.ws.rs-api/2.1.1/d3466bc9321fe84f268a1adb3b90373fc14b0eb5/javax.ws.rs-api-2.1.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/javax.ws.rs/javax.ws.rs-api/2.1.1/d3466bc9321fe84f268a1adb3b90373fc14b0eb5/javax.ws.rs-api-2.1.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:125) ~[javax.ws.rs-api-2.1.1.jar:2.1.1] RuntimeDelegate.java:125 at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:97) ~[javax.ws.rs-api-2.1.1.jar:2.1.1]

It seems the reason for this is because of an old version of the jersey-core:1.19.4 being used which I have tried to upgrade still that didn't work.

Here is my bean:

@Bean
@ConditionalOnMissingBean
public WorkflowClient getWorkflowClient() {
    WorkflowClient workflowClient = new WorkflowClient();
    workflowClient.setRootURI(env.getConductorServerUri());
    return workflowClient;
}

@Bean
@ConditionalOnMissingBean
public TaskClient getTaskClient() {

    TaskClient taskClient = new TaskClient();
    taskClient.setRootURI(env.getConductorServerUri());

    return taskClient;
}
...

And have the following in my implementing class

@Autowired
private WorkflowClient wfClient;

Is there a workaround to avoid this LinkageError?

Thanks

novotnymiro commented 1 year ago

Any update regarding this one? We are considering conductor as a workflow engine for our future project built on spring boot 3 and this is a blocker. Thank you

wy-hua commented 1 year ago

Hi, @novotnymiro @exelon-admin I ran into this error like you did. I figured out a workaround to bypass this error, which is using the gRPC client instead of HTTP client to interact with Conductor server. Here are steps you need to do

  1. Enable gRPC server in your Conductor server by adding conductor.grpc-server.enabled=true in your Conductor server's application.properties file. By default, the exposed port dealing with gRPC requests is 8090.

  2. Use the conductor-grpc-client dependency instead of the conductor-client. This package provides constructors like TaskClient(String address, int port) and the same APIs as those you probably will use in conductor-client.

bibibiu2017 commented 1 year ago

Hi everyone,

From my investigations, it seems like the issue stems from the fact that in spring boot 3 javax namespace was moved to jarkata This issue should be fixed by changing all dependencies from javax -> jarkata

If you still want to use the HTTP client a workaround would be to add these 2 dependencies

implementation("org.glassfish.jersey.core:jersey-common:2.34") implementation("javax.ws.rs:javax.ws.rs-api:2.1.1")