marklogic / java-client-api

Java client for the MarkLogic enterprise NoSQL database
https://docs.marklogic.com/guide/java
Apache License 2.0
59 stars 72 forks source link

marklogic-client-api jar in classpath causes ReST calls to to throw ClassNotFoundException #1669

Closed mathurashwin closed 4 months ago

mathurashwin commented 7 months ago

If you are a licensed MarkLogic customer, please contact Support first.

If you are a MarkLogic employee, please use our internal JIRA instance to report an issue of type Bug in the DHFPROD project.

Otherwise, please use this template to report the bug you've run into.

The issue

Please provide reproducible steps for the issue and a description of what behavior you expected instead.

The steps to reproduce the issue (use as many numbered steps as you need):

1) Create a java project with a ReST call using the jakarta JAX-RS api and have the marklogic-client-api jar and any other JAX-RS implementing jars like like CXF (cxf-rt-frontend-jaxrs), Resteasy, etc. in the classpath. Make sure the marklogic jar is BEFORE the other implementing jars (CXF, Resteasy, etc.) in the classpath. 2) When the rest call is invoked, you will see a ClassNotFoundException for the class org.glassfish.jersey.internal.RuntimeDelegateImpl

What behavior were you expecting? Expecting the rest call to go through without any errors as a valid implementation of JAX-RS is provided

Technical details

Please provide the following version information:

If this is a Hub Central or QuickStart issue, please provide the browser version too:

Additional details

This error happens because the marklogic-client-api jar contains a reference to the com.marklogic.client.impl.MockRuntimeDelegate class in the META-INF/services/javax.ws.rs.ext.RuntimeDelegate file. The JAX-RS api uses the ServiceLoader to look for implementations of javax.ws.rs.ext.RuntimeDelegate and picks the first it finds in the classpath which, in this case, will be the com.marklogic.client.impl.MockRuntimeDelegate class which it cannot find. It then defaults to the default class which is org.glassfish.jersey.internal.RuntimeDelegateImpl which isnt found as well and hence the ClassNotFoundException. I'm assuming the reference to the MockRuntimeDelegate class was put in there for some testing as its called a 'Mock' and this file should never have been packaged with the released jar file. Removing this file should fix this issue

rjrudin commented 6 months ago

Hi @mathurashwin - it sounds like this is generic to the MarkLogic Java Client and not to the Data Hub. Are you actually using https://central.sonatype.com/artifact/com.marklogic/marklogic-data-hub in your application, or just com.marklogic:marklogic-client-api?

rjrudin commented 6 months ago

Transferred this issue to the Java Client. @mathurashwin You're absolutely right in your diagnosis, I believe this file has long been overlooked. We'll get a patch release out very soon to remove the file.

Please let us know if you're using com.marklogic:marklogic-data-hub as a dependency or just com.marklogic:marklogic-client-api.

mathurashwin commented 6 months ago

Great!

I’m using the com.marklogic:marklogic-client-api dependency

On Jun 4, 2024, at 11:37 AM, Rob Rudin @.***> wrote:



Transferred this issue to the Java Client. @mathurashwinhttps://github.com/mathurashwin You're absolutely right in your diagnosis, I believe this file has long been overlooked. We'll get a patch release out very soon to remove the file.

Please let us know if you're using com.marklogic:marklogic-data-hub as a dependency or just com.marklogic:marklogic-client-api.

— Reply to this email directly, view it on GitHubhttps://github.com/marklogic/java-client-api/issues/1669#issuecomment-2147843365, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAUI63RCSJ5AKNAKP26DYPDZFXNJXAVCNFSM6AAAAABIYYZURSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHA2DGMZWGU. You are receiving this because you were mentioned.Message ID: @.***>

rjrudin commented 4 months ago

This will be in the next release (likely 6.7.0).

rjrudin commented 4 months ago

Addressed via #1670