服务或财产未注册的错误(Service or property not registered err

2019-10-21 01:27发布

只是当我运行这段代码:

Configuration azureConfig = ManagementConfiguration.configure(
    new URI("https://management.core.windows.net/"), 
    "asdasdasd",
    "server.keystore",
    "asdasdasd",
    KeyStoreType.jks
);
ManagementClient client = ManagementService.create(azureConfig);
LocationsListResponse response = client.getLocationsOperations().list();
ArrayList locations = response.getLocations();

for( int i=0; i<locations.size(); i++){
    System.out.println(((LocationsListResponse.Location)locations.get(i)).getDisplayName());
}

我得到这个:

00:52:04 [SEVERE] java.lang.RuntimeException: Service or property not registered: com.microsoft.windowsazure.management.ManagementClient interface com.microsoft.windowsazure.management.ManagementClient
00:52:04 [SEVERE]     at com.microsoft.windowsazure.core.DefaultBuilder.build(DefaultBuilder.java:197)
00:52:04 [SEVERE]     at com.microsoft.windowsazure.Configuration.create(Configuration.java:113)
00:52:04 [SEVERE]     at com.microsoft.windowsazure.management.ManagementService.create(ManagementService.java:46)
00:52:04 [SEVERE]     at {LINE OF CODE THAT CONTAINS ManagementClient client = ManagementService.create(azureConfig);}

在互联网上有只1这个问题,关于Android和不具有明确的答复......已经有人解决了这个问题?

我在虚拟机中使用Java 1.8中运行它OpenLogic 6.5(基于CentOS)下从Azure上。

编辑:我创建了一个新的项目,并从日食启动它。 我得到正确的结果,但是当我在命令行(Java的罐子Test.jar的)启动它我收到完全相同的错误。

Answer 1:

我也面临类似的问题。 明确设置上下文类加载器的问题解决了

// Get current context class loader
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); 
// Change context classloader to class context loader   
Thread.currentThread().setContextClassLoader(AzureManagementServiceDelegate.class.getClassLoader)); 
try { 
     // Call Azure API and reset back the context loader 
} catch (Exception e) {
    // handle exceptions  
} finally {
 // Reset back class loader
Thread.currentThread().setContextClassLoader(contextLoader); 
}


文章来源: Service or property not registered error
标签: java linux azure