Exception while adding Properties Metadata

63 views Asked by At

we are using the below code to add Properties Metadata to a document in MarkLogic but we are getting javax.xml.bind.DatatypeConverter exception.

DocumentMetadataHandle documentMetadataHandle = new DocumentMetadataHandle();
documentMetadataHandle.getProperties().put("test", "test");
XMLDocumentManager xmldocMgr = client.newXMLDocumentManager();
xmldocMgr.write("/test/sample", metadataHandle, domHandle);

We are using MarkLogic 10.0.-2.1 and the Java Client API version is 4.1.0

Exception is

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
    at com.marklogic.client.impl.ValueConverter.StringToString(ValueConverter.java:575)
    at com.marklogic.client.impl.ValueConverter.convertFromJava(ValueConverter.java:253)
    at com.marklogic.client.impl.ValueConverter.convertFromJava(ValueConverter.java:94)
    at com.marklogic.client.io.DocumentMetadataHandle.sendPropertiesImpl(DocumentMetadataHandle.java:888)
    at com.marklogic.client.io.DocumentMetadataHandle.sendMetadataImpl(DocumentMetadataHandle.java:791)
    at com.marklogic.client.io.DocumentMetadataHandle.write(DocumentMetadataHandle.java:575)
    at com.marklogic.client.impl.StreamingOutputImpl.writeTo(StreamingOutputImpl.java:58)
    at okhttp3.MultipartBody.writeOrCountBytes(MultipartBody.java:173)
    at okhttp3.MultipartBody.writeTo(MultipartBody.java:114)
    at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:69)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at com.burgstaller.okhttp.AuthenticationCacheInterceptor.intercept(AuthenticationCacheInterceptor.java:45)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
    at okhttp3.RealCall.execute(RealCall.java:81)
    at com.marklogic.client.impl.OkHttpServices.sendRequestOnce(OkHttpServices.java:706)
    at com.marklogic.client.impl.OkHttpServices.sendRequestOnce(OkHttpServices.java:701)
    at com.marklogic.client.impl.OkHttpServices.putPostDocumentImpl(OkHttpServices.java:1550)
    at com.marklogic.client.impl.OkHttpServices.putDocument(OkHttpServices.java:1260)
    at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:920)
    at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:758)
    at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:702)
    at com.lock.DemoApplication.createXMLDocument(DemoApplication.java:36)
    at com.lock.DemoApplication.main(DemoApplication.java:64)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 36 more

Please help us to fix this issue.

1

There are 1 answers

1
ehennum On BEST ANSWER

What Java version is used for the compilation?

Recent versions of Java have moved JAXB (including the data type converter routines) out of the core Java libraries and into optional download libraries.

Here's an example of how to add these dependencies using Gradle:

https://github.com/marklogic/java-client-api/blob/master/marklogic-client-api/build.gradle#L10-L14

Hoping that helps,