2015-12-03 72 views
1

我正在關注鏈接 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應用程序,該應用程序將從Web位置將WAR二進制文件部署到我的帳戶中。openshift,休息apis二進制部署

我正在

InboundJaxrsResponse {上下文= ClientResponse {方法= POST,URI = https://openshift.redhat.com/broker/rest/application/# {myAppID} /部署中,狀態= 422,原因=無法處理的實體}}作爲響應:

其中# {} 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兼容的部署文件夾,我放置了戰爭文件,並提供下載作爲copmressed .tar.gz文件,但同樣的問題 您的幫助是高度讚賞。 謝謝

+0

糾正,我使用的戰爭網址是:String url_of_war =「https://web-actions.googlecode.com/files/helloworld.war」; – user2778633

回答

0

二進制部署需要在一個非常特定的格式,他們不能只是一個戰爭文件(或壓縮戰爭文件)。

您應該查看關於在OpenShift Online上使用二進制部署的博客文章(https://blog.openshift.com/using-openshift-without-git/)以供進一步參考。我認爲這會幫助你讓你的代碼工作。

+0

謝謝你的回覆,其實這是我嘗試過的一件事情,我創建了一個部署文件夾結構,因爲這個網站提到並把內部的戰爭作爲ROOT.war放在特定的文件夾和tar gz文件夾中,正如我當我手動從rhc部署時,所以生成的二進制文件可手動部署,我可以從我自己的網站作爲可下載的lonk,我測試過,但它沒有工作 – user2778633