REST plugin conflicts with custom plugin

rest
#1

Hi,
Our custom plugin uses Jersey-2 for communication. If I add a “REST Web Services” node (optionally remove it) and execute our custom node, our node fails with error:
" Execute failed: java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl cannot be found by com.linguamatics.solutions.knime_1.6.0:",
see Stack trace (6.0 KB) for details.

This is happening because the “javax.ws.rs.client.ClientBuilder” system property is set to org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl when the REST node is added. See stack trace setting client builder property (5.4 KB)

I have experimented with one workaround:

  • Before executing our node
    • Save the system property javax.ws.rs.client.ClientBuilder
    • Clear the system property javax.ws.rs.client.ClientBuilder
  • After executing our node
    • Restore the system property javax.ws.rs.client.ClientBuilder

One disadvantage of this approach is that nodes cannot execute concurrently.

Other possible solutions (I have not experimented with these) are

  • Introduce a version of org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl in our bundle
  • Add a UTF-8 text file named “META-INF/services/javax.ws.rs.client.ClientBuilder” containing the fully qualified name of the builder class we want to use.

However above are workarounds, I prefer if the REST plugin didn’t set this system property.

Thanks
Wiraj

0 Likes

#2

Our REST nodes rely on CXF therefore we force its usage by setting those properties. Otherwise other plug-ins could inject other JAX-RS libraries that may break our nodes. If possible I suggest that you also use CXF instead of Jersey in your plug-in.
The “META-INF” approach may also work and you could also instantiate the Jersey client directly if you really need to use Jersey.

0 Likes

#3

Our KNIME nodes are driven by an internal SDK that uses Jersey-2. Changing this SDK is a lot more work and could affect other uses of the SDK. The META-INF workaround seems to work.
Thanks,
Wiraj

0 Likes