سؤال

When i use the following to create a table in azure ( java )

CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
CloudTableClient tableClient = storageAccount.createCloudTableClient();
CloudTable table = tableClient.getTableReference("people");
table.createIfNotExist();

i receive the following exception:

java.lang.NoSuchMethodError: com.microsoft.windowsazure.services.table.client.CloudTableClient.getTableReference(Ljava/lang/String;)Lcom/microsoft/windowsazure/services/table/client/CloudTable;

I use the following lib: microsoft-windowsazure-api-0.4.6.jar. All the other calls to the table works perfectly.

When i use microsoft-windowsazure-api-0.2.2.jar i had to use createTableIfNotExists method and this worked perfectly for me. But like to update the lib for better fault handling.

Has anybody encountered the same problem? Any help is appreciated!

هل كانت مفيدة؟

المحلول

I just tried with the following code and it worked fine for me:

package TestPackage;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.table.client.*;

public class TestClass {
    public static void main(String[] args) throws URISyntaxException, StorageException, InvalidKeyException {
        CloudStorageAccount storageAccount =
                CloudStorageAccount.parse("UseDevelopmentStorage=true");

            // Create the table client.
            CloudTableClient tableClient = storageAccount.createCloudTableClient();

            // Create the table if it doesn't exist.
            String tableName = "people";
            CloudTable table = tableClient.getTableReference(tableName);
            table.createIfNotExist();
            //tableClient.createTableIfNotExists(tableName);

            System.console().readLine();
    }

}

and screenshot below shows all libraries I referenced

enter image description here

نصائح أخرى

After the tip that it works in a small program, i started to copy step by step my code and libs from the project that didn't work to an small project thats works.

I noticed that when i copied al my libs to the new project it stoped working.Then i saw i had also the old Azure 0.2.2 lib in my lib directory. This one was not in the build path so it compiled perfectly and everywhere worked except making an new table.

When i remove my old azure lib everything was working like a charm.

Thanks for helping.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top