Azure / azure-storage-java

Microsoft Azure Storage Library for Java
https://docs.microsoft.com/en-us/java/api/overview/azure/storage
MIT License
189 stars 164 forks source link

package com.microsoft.azure.storage does not exist - Azure Storage SDK client on Ubuntu #184

Closed mohzen closed 6 years ago

mohzen commented 7 years ago

Hello,

I am trying to build Java applications using the Azure Storage SDK client libraries on Ubuntu 16.04. I have downloaded the latest version of Azure Storage SDK from GitHub and MVN build is successful. However when i try to run sample programs the following errors are seen BlobSample.java:3: error: package com.microsoft.azure.storage does not exist import com.microsoft.azure.storage.; BlobSample.java:4: error: package com.microsoft.azure.storage.blob does not exist import com.microsoft.azure.storage.blob.; Just wondering if a) Any dependency service that has to be installed. b) Any issue with the build PATH settings?The current PATH settings looks fine echo $PATH /usr/lib/jvm/java-8-openjdk-amd64/jre/bin

Thanks and Regards.

jofri-msft commented 7 years ago

Hi @mohzen , are you saying you only notice this issue with the 5.3.1 release? Because though I have verified that the release works on windows. I don't think ubuntu would use different servers but you can check again tomorrow after it has had time to propagate. I would also verify your maven path and see if you are able to download and use other maven dependencies successfully.

Make sure your pom.xml contains

com.microsoft.azure azure-storage 5.3.1
mohzen commented 7 years ago

Hi @jofriedm-msft,

Many thanks for the quick response. Just checked the pom.xml file, doesn't contain "com.microsoft.azure azure-storage 5.3.1" and also the version is shown as 5.3.0. I haven't tried this on any previous release yet, will try this with an older release and let you know. Thanks and Regards, Mohan

mohzen commented 7 years ago

Hi @jofriedm-msft,

The Maven was installed using the normal apt-get repos and the Maven file structure is installed in the folders /etc/alternatives, /usr/bin, /usr/share and /var/lib by default. The Azure Storage SDK was installed by cloning to the home directory and i can see the $PATH is set to point to the home and /usr/bin directories. Not sure if the $PATH has to be modified to point back to the /usr/share and /var/lib directories.

Thanks again. Mohan

mohzen commented 7 years ago

I have tried this now and MVN compile is successful and the target file is generated for the source files. However, when i execute the java "Target_File_Name" (without the class suffix), errors are seen with the following exceptions: Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonFactory at com.microsoft.azure.storage.core.Utility.(Utility.java:132) at com.microsoft.azure.storage.CloudStorageAccount.parse(CloudStorageAccount.java:242) at BlobSample.main(BlobSample.java:30) Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more Updated JSON Dependency to version 2.8.9 in the pom.xml file and recompile builds with success. But JSON errors are still seen upon execution of the *.class file in the target subdirectory.

com.fasterxml.jackson.core jackson-core 2.8.9
jofri-msft commented 7 years ago

Hi @mohzen , what IDE are you using? For intellij if you go to File->Settings->Build, Execution, Deployment ->Build Tools->Maven->Importing, there is an option to Import Maven projects automatically. Also our pom.xml does not use the 2.8.9 version and compiles fine https://github.com/Azure/azure-storage-java/blob/master/pom.xml. There is a also a pom.xml in our samples which you can use a reference https://github.com/Azure/azure-storage-java/blob/master/pom.xml

mohzen commented 7 years ago

Hi jofriedm-msft,

Thanks for your reply. I was testing this on Eclipse Neon IDE, but my colleague got it going on STS (Spring Tool Suite). I switched to STS as well and had it working after manually installing the Jackson Factory 2.6.0 jar as an External Jar in Maven dependency! I will test this on intellij IDE soon.

By the way, i am now testing this setup on a Ubuntu VM without the STS IDE as there are other apps running on the VM and would like to keep it light. Wondering which directory should i place the jar files?

Many thanks again for your help and advice. Mohan