- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试访问OpenStack Swift使用Apache JClouds 1.9.2 库。 Maven 依赖:
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-all</artifactId>
<version>1.9.2</version>
</dependency>
我从 getting started guide 开始及其代码示例。一般来说,我连接和保存 blob 没有问题。但是,当我尝试列出容器列表(或容器的内容)时,出现以下错误:
SEVERE: Error parsing input: java.lang.IllegalStateException:
Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
at com.google.gson.Gson.fromJson(Gson.java:817)
at com.google.gson.Gson.fromJson(Gson.java:770)
at com.google.gson.Gson.fromJson(Gson.java:719)
at org.jclouds.json.internal.GsonWrapper.fromJson(GsonWrapper.java:42)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:83)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:77)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:62)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:42)
at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:90)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44)
at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
at com.sun.proxy.$Proxy57.list(Unknown Source)
Caused by: java.lang.IllegalStateException:
Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:351)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.readAndBuild(NullFilteringTypeAdapterFactories.java:88)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:82)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$FluentIterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:239)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$FluentIterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:225)
at com.google.gson.Gson.fromJson(Gson.java:805)
下面的代码取自示例,执行 containerApi.list()
时将失败。正如所评论的,方法createContainer
和uploadObjectFromString
将起作用。
我只能认为 Swift 返回的 JSON 格式的响应与 JClouds 期望的略有不同,但我不知道这是否属实或如何解决。另外,我在 OpenStack 仪表板中看到,虽然对象存储是 http://xx.xx.xx.107:80/swift/v1身份是http://xx.xx.xx.101:5000/v2.0不确定为什么其中一个是 v1,另一个是 v2.0,以及在使用 Java 库时是否应该考虑这一点。我认为我对使用哪些 Java 库没有限制,所以我想知道是否最好使用另一个库而不是 JClouds,尽管这个看起来是最合适的。
import java.io.Closeable;
import java.io.IOException;
import java.util.Set;
import org.jclouds.ContextBuilder;
import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.domain.Container;
import org.jclouds.openstack.swift.v1.features.ContainerApi;
import com.google.common.io.Closeables;
public class JCloudsSwift implements Closeable {
private SwiftApi swiftApi;
public static void main(String[] args) {
JCloudsSwift jcloudsSwift = new JCloudsSwift();
try {
jcloudsSwift.listContainers();
jcloudsSwift.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
jcloudsSwift.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public JCloudsSwift() {
String provider = "openstack-swift";
String identity = "tenantName:userName";
String credential = "password";
String endPoint = "http://xx.xx.xx.101:5000/v2.0/";
swiftApi = ContextBuilder.newBuilder(provider)
.endpoint(endPoint)
.credentials(identity, credential)
.buildApi(SwiftApi.class);
}
private void listContainers() {
String region = "us-east-1a";
ContainerApi containerApi = swiftApi.getContainerApi(region);
Set<Container> containers = containerApi.list().toSet();
for (Container container : containers) {
System.out.println(" " + container);
}
}
public void close() throws IOException {
Closeables.close(swiftApi, true);
}
}
按照 zachsh 的建议,我启用了线路日志(见下文)。我隐藏了一些细节(IP...)。希望我没有在那里妥协任何事情。
在我看来,首先,有一个对身份 v2 端点的调用,它会获取一个提供不同端点的有效 JSON 响应,就像 swift v1 的端点一样。请求和响应中的内容类型都是application/json
。然后,调用这个 swift 端点,但它只会返回纯文本响应。也就是说,请求中的请求内容类型是 application/json
,而响应中的请求内容类型是 text/plain
。 “Dev”和“dev2”是对象存储中两个容器的名称。
我想知道我的Java代码是否有什么问题(我主要复制了示例,但我可能配置错误),或者我使用的库有什么问题,甚至我的Openstack安装中有什么问题(我无法控制它) ,但我可以询问具体细节)。
请参阅下面的日志。
jclouds-wire.log
2016-02-17 09:31:04,562 DEBUG [jclouds.wire] [main] >> "Sensitive data in payload, use PROPERTY_LOGGER_WIRE_LOG_SENSITIVE_INFO override to enable logging this data."
2016-02-17 09:31:04,562 DEBUG [jclouds.headers] [main] >> POST http://xx.xx.xx.101:5000/v2.0/tokens HTTP/1.1
2016-02-17 09:31:04,562 DEBUG [jclouds.headers] [main] >> Accept: application/json
2016-02-17 09:31:04,562 DEBUG [jclouds.headers] [main] >> Content-Type: application/json
2016-02-17 09:31:04,562 DEBUG [jclouds.headers] [main] >> Content-Length: 103
2016-02-17 09:31:04,984 DEBUG [jclouds.headers] [main] << HTTP/1.1 200 OK
2016-02-17 09:31:04,984 DEBUG [jclouds.headers] [main] << X-Distribution: Ubuntu
2016-02-17 09:31:04,984 DEBUG [jclouds.headers] [main] << Connection: keep-alive
2016-02-17 09:31:04,984 DEBUG [jclouds.headers] [main] << Vary: X-Auth-Token
2016-02-17 09:31:04,984 DEBUG [jclouds.headers] [main] << Date: Wed, 17 Feb 2016 09:31:27 GMT
2016-02-17 09:31:04,984 DEBUG [jclouds.headers] [main] << Content-Type: application/json
2016-02-17 09:31:04,984 DEBUG [jclouds.headers] [main] << Content-Length: 4421
2016-02-17 09:31:04,999 DEBUG [jclouds.wire] [main] << "{"access": {"token": {"issued_at": "2016-02-17T09:31:27.785179", "expires": "2016-02-17T10:31:27Z", "id": "fb6b46bd674046ef87c3270f1fd9dafd", "tenant": {"description": "", "enabled": true, "id": "c2c919f7f89a4d8f913e4ce19a0e6ace", "name": "my_tenant_name"}, "audit_ids": ["nIjY-heVSV-cbTfVIpEY-Q"]}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://xx.xx.xx.102:8774/v2/c2c919f7f89a4d8f913e4ce19a0e6ace", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.102:8774/v2/c2c919f7f89a4d8f913e4ce19a0e6ace", "id": "70c3eef4d3e242348c0e580f94414823", "publicURL": "http://xx.xx.xx.102:8774/v2/c2c919f7f89a4d8f913e4ce19a0e6ace"}], "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.105:9696", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.105:9696", "id": "2a9328b17cc54538a38fb6ae13e5b3ac", "publicURL": "http://xx.xx.xx.105:9696"}], "endpoints_links": [], "type": "network", "name": "quantum"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.104:8776/v2/c2c919f7f89a4d8f913e4ce19a0e6ace", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.104:8776/v2/c2c919f7f89a4d8f913e4ce19a0e6ace", "id": "2eda4420ba0a49f9891ed9bd803b569c", "publicURL": "http://xx.xx.xx.104:8776/v2/c2c919f7f89a4d8f913e4ce19a0e6ace"}], "endpoints_links": [], "type": "volumev2", "name": "cinderv2"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.102:3333", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.102:3333", "id": "538aab805479410da21399abd012ceff", "publicURL": "http://xx.xx.xx.102:3333"}], "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.103:9292", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.103:9292", "id": "80559923bf354541bdd9f56a45bedd7a", "publicURL": "http://xx.xx.xx.103:9292"}], "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.108:8777", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.108:8777", "id": "a777efdc724643ecb6e705ff2eb47004", "publicURL": "http://xx.xx.xx.108:8777"}], "endpoints_links": [], "type": "metering", "name": "ceilometer"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.220:8000/v1", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.220:8000/v1", "id": "253135e684c24e00bb7bea6feb7cf595", "publicURL": "http://xx.xx.xx.220:8000/v1"}], "endpoints_links": [], "type": "cloudformation", "name": "heat-cfn"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.104:8776/v1/c2c919f7f89a4d8f913e4ce19a0e6ace", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.104:8776/v1/c2c919f7f89a4d8f913e4ce19a0e6ace", "id": "38264ccfbb574fcd81ba345c9eb7d37b", "publicURL": "http://xx.xx.xx.104:8776/v1/c2c919f7f89a4d8f913e4ce19a0e6ace"}], "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.102:8773/services/Cloud", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.102:8773/services/Cloud", "id": "4da43f1139c94d8aaf82564e16156ca5", "publicURL": "http://xx.xx.xx.102:8773/services/Cloud"}], "endpoints_links": [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.220:8004/v1/c2c919f7f89a4d8f913e4ce19a0e6ace", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.220:8004/v1/c2c919f7f89a4d8f913e4ce19a0e6ace", "id": "1180dc51deea4523a088871a352d9f72", "publicURL": "http://xx.xx.xx.220:8004/v1/c2c919f7f89a4d8f913e4ce19a0e6ace"}], "endpoints_links": [], "type": "orchestration", "name": "heat"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.107:80/swift", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.107:80/swift/v1", "id": "0457cd31064243c9b548dfe2eb0c1bc8", "publicURL": "http://xx.xx.xx.107:80/swift/v1"}], "endpoints_links": [], "type": "object-store", "name": "swift"}, {"endpoints": [{"adminURL": "http://xx.xx.xx.101:35357/v2.0", "region": "us-east-1a", "internalURL": "http://xx.xx.xx.101:5000/v2.0", "id": "40d04c8899cc4ea083dc5ecac808a825", "publicURL": "http://xx.xx.xx.101:5000/v2.0"}], "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": "my_user_name", "roles_links": [], "id": "e9312e8a3579404d91ba53894dcf72ea", "roles": [{"name": "Member"}, {"name": "_member_"}], "name": "my_user_name"}, "metadata": {"is_admin": 0, "roles": ["647df06e706f4d1f8a8810246e19bd26", "9fe2ff9ee4384b1894a90878d3e92bab"]}}}"
2016-02-17 09:31:05,062 DEBUG [jclouds.headers] [main] >> GET http://xx.xx.xx.107:80/swift/v1 HTTP/1.1
2016-02-17 09:31:05,062 DEBUG [jclouds.headers] [main] >> Accept: application/json
2016-02-17 09:31:05,062 DEBUG [jclouds.headers] [main] >> X-Auth-Token: fb6b46bd674046ef87c3270f1fd9dafd
2016-02-17 09:31:05,405 DEBUG [jclouds.headers] [main] << HTTP/1.1 200 OK
2016-02-17 09:31:05,405 DEBUG [jclouds.headers] [main] << Content-type: text/plain; charset=utf-8
2016-02-17 09:31:05,405 DEBUG [jclouds.headers] [main] << Connection: Keep-Alive
2016-02-17 09:31:05,405 DEBUG [jclouds.headers] [main] << Date: Wed, 17 Feb 2016 09:31:28 GMT
2016-02-17 09:31:05,405 DEBUG [jclouds.headers] [main] << Content-Type: text/plain; charset=utf-8
2016-02-17 09:31:05,405 DEBUG [jclouds.headers] [main] << Content-Length: 9
2016-02-17 09:31:05,405 DEBUG [jclouds.wire] [main] << "dev[\n]"
2016-02-17 09:31:05,405 DEBUG [jclouds.wire] [main] << "dev2[\n]"
jclouds.log
2016-02-17 09:31:04,562 DEBUG [org.jclouds.rest.internal.InvokeHttpMethod] [main] >> invoking AuthenticationApi.authenticateWithTenantNameAndCredentials
2016-02-17 09:31:04,562 DEBUG [org.jclouds.http.internal.JavaUrlHttpCommandExecutorService] [main] Sending request -1271935931: POST http://xx.xx.xx.101:5000/v2.0/tokens HTTP/1.1
2016-02-17 09:31:04,984 DEBUG [org.jclouds.http.internal.JavaUrlHttpCommandExecutorService] [main] Receiving response -1271935931: HTTP/1.1 200 OK
2016-02-17 09:31:05,046 DEBUG [org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToURIFromAccessForTypeAndVersion] [main] endpoints for apiType object-store and version 1: {us-east-1a=[Endpoint{id=0457cd31064243c9b548dfe2eb0c1bc8, region=us-east-1a, publicURL=http://xx.xx.xx.107:80/swift/v1, internalURL=http://xx.xx.xx.107:80/swift/v1, adminURL=http://xx.xx.xx.107:80/swift}]}
2016-02-17 09:31:05,062 DEBUG [org.jclouds.rest.internal.InvokeHttpMethod] [main] >> invoking container:list
2016-02-17 09:31:05,062 DEBUG [org.jclouds.http.internal.JavaUrlHttpCommandExecutorService] [main] Sending request -629919459: GET http://xx.xx.xx.107:80/swift/v1 HTTP/1.1
2016-02-17 09:31:05,405 DEBUG [org.jclouds.http.internal.JavaUrlHttpCommandExecutorService] [main] Receiving response -629919459: HTTP/1.1 200 OK
2016-02-17 09:31:05,420 ERROR [org.jclouds.http.functions.ParseJson] [main] Error parsing input: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
at com.google.gson.Gson.fromJson(Gson.java:817)
at com.google.gson.Gson.fromJson(Gson.java:770)
at com.google.gson.Gson.fromJson(Gson.java:719)
at org.jclouds.json.internal.GsonWrapper.fromJson(GsonWrapper.java:42)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:83)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:77)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:62)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:42)
at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:90)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44)
at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
at com.sun.proxy.$Proxy57.list(Unknown Source)
at com.ceph.JCloudsSwift.listContainers(JCloudsSwift.java:58)
at com.ceph.JCloudsSwift.main(JCloudsSwift.java:22)
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:351)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.readAndBuild(NullFilteringTypeAdapterFactories.java:88)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:82)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$FluentIterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:239)
at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$FluentIterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:225)
at com.google.gson.Gson.fromJson(Gson.java:805)
... 15 common frames omitted
最佳答案
看起来像一个错误。谢谢!将在这里跟踪:https://issues.apache.org/jira/browse/JCLOUDS-1080
关于java - JClouds 和 OpenStack : IllegalStateException: Expected BEGIN_ARRAY but was STRING,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35439056/
我有一个 openstack私有(private)云部署在我的组织中。我有一些 虚拟图像 比如通过openstack仪表板上传的ubuntu图像、windows图像。但我想知道图像存储位置在 open
我感兴趣如何向其他应用程序通知 openstack 中的事件。例如,我不想在我的应用程序中知道 nova 中的实例何时被挂起或恢复。是否有任何网络钩子(Hook)或类似的东西我可以在哪里获取该信息?
我在 CentOs VM 上安装了 Openstack,当我尝试查看已启动实例的列表时,出现此错误 $ openstack server list Ignoring domain related co
在我的本地机器上使用 CreateObjectFromFile 方法将文件上传到机架空间云时,虽然没问题。但是当我从客户端机器执行此操作时,我得到 net.openstack.Core.Excepti
我正在通过 this 在我的本地机器上安装 OpenStack关联。但是我无法从本地计算机中完全删除已安装的组件。我运行了以下命令:- $ sudo ./unstack.sh tgtadm: can'
当我向 OpenStack-ansible 添加新的计算节点时,一切似乎都正常,但无法在其上创建任何实例 NoValidHost: No valid host was found. There are
我需要将一些字节附加到存储在 Openstack Swift 中的现有对象,例如日志文件对象,并不断向其附加新日志。这可能吗? 此外,我可以将一些字节(指定偏移量和长度)更改(覆盖)到现有对象吗? 最
我目前正在研究 OpenStack,并想了解可用于调试在 VM 上运行时出现的不同问题的开发环境。通过开发环境,我指的是可以帮助我理解 OpenStack 的功能和调用流程的 IDE。我在我的机器上安
OpenStack“Heat”的编排引擎可以部署计算资源和配置软件,称为 HOT 模板。 github 上有很多例子: https://github.com/openstack/heat-templa
如何重新启动使用 devstack 安装的特定 openstack-service? 最佳答案 重新加入堆栈屏幕为 ./rejoin-stack.sh 并使用 ctrl+a+"移动到指定的服务页面,然
我已经使用 devstack 安装了开放堆栈。推出了 ciros 镜像。我可以从 VNC 控制台连接到该实例,但无法 ping 到该实例。 最佳答案 您应该将安全组配置为允许传入 ICMP (ping
我尝试使用 Terraform 创建 OpenStack 实例,但收到以下错误: Error applying plan: 1 error(s) occurred: * openstack_compu
有人知道获取用户租户列表的方法吗?我知道我可以获得租户的用户,我可以获得所有租户的列表,所以从技术上讲,我可以遍历所有租户并寻找特定用户,但这似乎是一种麻烦的方法。 最佳答案 不知道 keystone
我是 OpenStack 的新手,我需要更改当前设置为 80 的 dashboard(horizon) 的默认 http 端口。我已经使用 devstack 脚本安装/部署了 OpenStack。
也许我的问题没有意义,但这就是我想要做的: 我有一个运行在 CoreOS 上的裸机 Kubernetes 集群。 我正在尝试使用 Cinder 从 OpenStack 云提供商挂载块存储。 根据我的阅
我想用 microStack 设置一个多节点 OpenStack,但它总是失败。 我正在关注这个:https://ubuntu.com/openstack/install#multi-node-dep
注意:我看到这个问题和错误被发布在不同的论坛和这里,但没有一个对我有用,它们属于 openstack 的早期版本。所以,我发布了一个新问题。 我一直在根据其安装文档设置 OpenStack Train
我是 openstack heat 文件的新手。我进行了搜索,但没有找到与我的问题相关的答案。这是我的模板热 yaml 文件: heat_template_version: newton descri
按照文档的步骤 http://docs.openstack.org/developer/swift/overview_large_objects.html 我成功地放入了 3 个段文件和 1 个 li
如何配置 OpenStack SWIFT 以发送所有适当的 CORS header 以响应客户端的 OPTIONS 请求?我知道 SWIFT 管道的跨域插件,但文档只说允许如下内容: [filter:
我是一名优秀的程序员,十分优秀!