Jersey 2 conflicts with jersey 1 from the "Apache Spark" extension

Hi,
We developed some KNIME extensions that make use of Jersey 2. When we install the “Apache Spark” extension, Jersey 1.0 (possibly from “Apache Spark”) starts conflicting with Jersey 2.0.

We’re not exporting the jersey 2 library from our bundle. Is there anything I can do to fix this, or is this a problem with the “Apache Spark” extension? Any input will be appreciated.
Thank You,
Wiraj

Exhibits:

  • With both extensions installed I get the following error when I try to run the nodes using Jersey 2. I

    ERROR I2E Query Submitter 0:1 Execute failed: HTTP request/response processing failure: A MultiException has 2 exceptions. They are:

    1. java.lang.ClassCastException: com.sun.jersey.core.impl.provider.entity.StringProvider cannot be cast to javax.ws.rs.ext.MessageBodyReader
    2. java.lang.IllegalStateException: Unable to perform operation: create on org.glassfish.jersey.message.internal.MessageBodyFactory
  • Attachment containing full stack trace: stack-trace.txt (11.7 KB)

Hi @wbibile,
Can you share the MANIFEST.MF file of the plugin with me? That might tell me if there is a configuration issue on your side. As a first guess, are you using import package in your plugin dependencies somewhere? This is a common cause for such issues.
Something you should also test is if the spark nodes still work if your plugin is installed, or do they also fail?

best,
Gabriel

Hi @gab1one
I don’t see any import package statements in our MANIFEST.MF (see attached file). Also thanks for your advice, I will make sure that the sparks plugin also works.

Thanks,
Wiraj

MANIFEST.MF file: MANIFEST.MF.txt (1.8 KB)

This was caused by ServiceFinderBinder.configure() scanning all JAR files for HK2 service providers. Can be fixed by turning off manifest service look up as follows.

import org.glassfish.jersey.CommonProperties;
import org.glassfish.jersey.client.ClientConfig;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Client;
       .
       .
    ClientConfig config = new ClientConfig();
    config.property(CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE,  Boolean.TRUE)
       .
       .
    Client client = ClientBuilder.newClient(config);
2 Likes

Thank you for reporting back your solution :slight_smile:
best,
Gabriel

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.