【问题标题】:openshift, rest apis binary deploymentopenshift、rest apis 二进制部署
【发布时间】:2015-12-03 02:26:10
【问题描述】:

我正在关注链接 https://access.redhat.com/documentation/en-US/OpenShift_Enterprise/2/pdf/REST_API_Guide/OpenShift_Enterprise-2-REST_API_Guide-en-US.pdf 构建我的 rest api java 应用程序,它将一个 WAR 二进制文件从 Web 位置部署到我的帐户中。

我得到了

InboundJaxrsResponse{context=ClientResponse{method=POST, uri=https://openshift.redhat.com/broker/rest/application/#{myAppID}/deployments, status=422, reason=Unprocessable Entity}} 作为响应:

#{myAppID} 是我为安全起见在此处替换的应用程序 uuid

我正在使用 glassfish rest api,我的代码是:

    String url_of_war = "https://code.google.com/p/web-actions/downloads/detail?name=helloworld.war";
    WebTarget webtarget;
    Client client
    HostnameVerifier hostnameVerifier = new HostnameVerifier() {
    @Override
    public boolean verify(String arg0, SSLSession arg1) {
    return true;
    }
    };
    client = ClientBuilder.newBuilder().sslContext(trustAllCertificates()).hostnameVerifier(hostnameVerifier ).build();
    }
    URIBuilder uriBuilder = new URIBuilder();
    try {
      uriBuilder = uriBuilder.setScheme("https").setHost("openshift.redhat.com/broker/rest/").setPath("application/#{myAppId}/deployments");
      if (getPort() > 0) {
        uriBuilder = uriBuilder.setPort(getPort());
      }
      URI uri = uriBuilder.build();
      webtarget = client.target(uri);
    } catch (Exception e) {
      String msg = "Could not build URI!";
      throw new RuntimeException(msg, e);
    }
    Invocation.Builder invocationBuilder = webtarget.request(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE);
    invocationBuilder.header("Authorization", "Basic "+Base64.encodeBase64String("#{myuser}:#{mypass}".getBytes()));
    Form form = new Form();
    form.param("hot_deploy", "false");
    form.param("force_clean_build", "false");
    form.param("artifact_url", URLEncoder.encode(url_of_war, "UTF-8"));
    Response response = invocationBuilder.post(Entity.form(form));       

我在这里做错了什么,自从 30 天以来,我一直在这个问题上没有任何线索,我还尝试创建与 openshift/jboss 兼容的部署文件夹,我在其中放置了 war 文件并可以作为压缩的 .tar 下载.gz 文件但同样的问题 非常感谢您的帮助。 谢谢

【问题讨论】:

标签: rest openshift


【解决方案1】:

二进制部署需要采用非常特定的格式,它们不能只是一个战争文件(或压缩的战争文件)。

您应该查看这篇关于在 OpenShift Online 上使用二进制部署的博客文章 (https://blog.openshift.com/using-openshift-without-git/) 以供进一步参考。我认为这将帮助您使您的代码正常工作。

【讨论】:

  • 谢谢您的回复,实际上这是我尝试过的事情之一,我创建了一个部署文件夹结构,正如本网站提到的那样,并将战争作为 ROOT.war 放入特定文件夹和 tar gz 文件夹,就像我从 rhc 手动部署时一样,因此生成的二进制文件可以手动部署,我将其作为可下载的 lonk 从我自己的网站提供,我测试过,但它没有工作
猜你喜欢
  • 1970-01-01
  • 2020-09-10
  • 2018-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-17
相关资源
最近更新 更多