avro-tools-1.8.2 jar conflicts with jakarta.ws.rs-api jar

30 Views Asked by At

We have an application that has been running for years now and is in production too in multiple places.

We use some functionality from the Jakarta.ws.rs-api.jar file. The following line is of interest though:

    Client client;
    WebTarget webTarget = client.target(url);
Invocation.Builder invocationBuilder = webTarget.request("application/json");

We are now trying to add Avro-tools-1.8.2.jar to our product as we need that for some new features we are implementing. However, I see that when we add this new jar file, the above lines don't work anymore. The line above returns a null WebTarget when we add Avro-tools-1.8.2.jar file to our project. These lines are a problem -

    WebTarget webTarget = client.target(url);
Invocation.Builder invocationBuilder = webTarget.request("application/json");

With the new changes, webTarget shows the following value:

com.sun.jdi.InvocationException: Exception occurred in target VM occurred invoking method.

And the line after that crashes.

Looks like there is an exception thrown while creating it. As mentioned above, if we run this without the Avro-tools jar file, it works perfectly fine.

Unfortunately, we need both Avro and Avro-tools for our new feature. So, removing Avro-tools itself is not an option.

I tried upgrading Avro and Avro-tools to a higher version (1.9.2) to see if it solves the issue. But still see the issue.

In addition, I also checked the contents of the Avro-tools-1.8.2 jar file and see that it does not have the above problematic classes at all - Client and WebTarget. So, the question of conflict does not arise.

I even tried to see if we can get this done without Avro-tools jar itself. But that is not possible. we read a schema and then convert an incoming JSON to the Avro schema compliant JSON. This functionality needs Avro-tools jar file as per my investigation.

Some questions:

  1. Has anyone faced a similar issue? When I do a google search, I don't get anything.
  2. Any inputs on how this can be resolved.
  3. Lastly, is there a way I can bypass Avro-tools jar itself? I am reading a schema and using that to convert an incoming JSON request to an Avro-compliant JSON. From what I see, both Avro and Avro-tools are needed. (Even though ChatGPT claims otherwise)

Thanks in advance. Om


Update:

I did some investigation and saw the following exception:

java.lang.NoSuchMethodError: javax.ws.rs.core.MultivaluedMap.addAll(Ljava/lang/Object;[Ljava/lang/Object;)V

I see that a class called javax.ws.rs.core.MultivaluedMap exists in both Avro-tools-1.8.2.jar and jakarta.ws.rs-api-2.1.6.jar. However, only jakarta.ws.rs-api-2.1.6.jar has the addAll function mentioned above. Avro-tools-1.8.2.jar does not have that function.

So, it looks like in my case, it may be using the Avro-tools-1.8.2.jar file. Any inputs on how I can fix this? I want my code to pick up Avro-tools-1.8.2.jar at runtime only for some specific classes. Not for the rest. (In code, I am already ensuring this during compilation). The avro-tools-1.8.2.jar and the jakarta.ws.rs-api-2.1.6.jar are both part of a war that has many other jars too.

0

There are 0 best solutions below