I have a spring application which, when I include the latest azure storage blob library:
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.14.0</version>
It changes my responses from Controllers to XML. I found this issue (https://github.com/Azure/azure-sdk-for-java/issues/7694) which seemed to fix my problem by excluding the XML data formatter like so:
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.14.0</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</exclusion>
</exclusions>
My responses changed back to JSON, but when I try to use the library, I get a NoClassDefFoundError error:
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/dataformat/xml/XmlMapper$Builder
at com.azure.storage.blob.implementation.util.ModelHelper.<clinit>(ModelHelper.java:53)
at com.azure.storage.blob.BlobUrlParts.parse(BlobUrlParts.java:371)
at com.azure.storage.blob.BlobServiceClientBuilder.endpoint(BlobServiceClientBuilder.java:147)
at com.azure.storage.blob.BlobServiceClientBuilder.connectionString(BlobServiceClientBuilder.java:286)
at util.AzureUtil.blobClient(AzureUtil.java:47)
at util.AzureUtil.getSecureReadParams(AzureUtil.java:24)
at util.AzureUtil.getFullSecuredURL(AzureUtil.java:35)
at RestServer.fabric.FilesFabric.getPresignedGetUrl(FilesFabric.java:37)
at RestServer.controllers.api.FilesController.getSecureFileUrl(FilesController.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1063)
... 96 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.dataformat.xml.XmlMapper$Builder
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 116 more
I could, theoretically, decorate all my Controllers' @RequestMapping
with produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE
to tell the controllers to use JSON, but this seems like a hacky workaround. Is there any way to get the Azure Blob library to leave my responses alone, but still work?