Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7866853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:31:55+00:00 2026-06-03T00:31:55+00:00

How to deploy archive to Jboss as 7 using HTTP managment api? I tryied

  • 0

How to deploy archive to Jboss as 7 using HTTP managment api?

I tryied to use the following code that I created from those RHQ plugin classes

public class Main2 {

public static final String MANAGEMENT = "/management";

public static void main(String[] args) throws ClientProtocolException, IOException {

    String runtimeName= "jboss-as-numberguess33.war";
    String filename = "/Users/mac/jboss-as-numberguess.war";
    String deploymentName="jboss-as-numberguess.war";
    File file=new File(filename);

    //STEP 1 UPLOADING
    ASUploadConnection uploadConnection=new ASUploadConnection("localhost", 9990,"username", "password");
    uploadConnection.getOutputStream(filename);
    JsonNode uploadResult = uploadConnection.finishUpload();


    if (ASUploadConnection.isErrorReply(uploadResult)) {
        System.out.println("Error reply");
    }
    else{
        JsonNode resultNode = uploadResult.get("result");
        String hash = resultNode.get("BYTES_VALUE").getTextValue();
        System.out.println(uploadResult);
        //--------------------------------------


        //STEP 2 DEPLOING
        System.out.println("Deploying [" + runtimeName + "] to server");


        Operation step1 = new Operation("add", "deployment", runtimeName);
        step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
        List<Object> content = new ArrayList<Object>(1);
        Map<String, Object> contentValues = new HashMap<String, Object>();
        contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
        content.add(contentValues);
        step1.addAdditionalProperty("content", content);

        step1.addAdditionalProperty("name", deploymentName);
        step1.addAdditionalProperty("runtime-name", runtimeName);
        CompositeOperation cop = new CompositeOperation();
        cop.addStep(step1);

        Operation step2 = new Operation("deploy", step1.getAddress());
        cop.addStep(step2);


        execute(cop);



    }
}

private static void execute(Operation operation) throws JsonGenerationException, JsonMappingException, IOException {
    long requestStartTime = System.currentTimeMillis();
    int timeoutSec=10;
    HttpURLConnection conn=null;
    OutputStream out;
    try {
        URL url = new URL("http", "localhost", 9990, MANAGEMENT);

        conn = (HttpURLConnection) url.openConnection();

        System.out.println(conn.getURL());
        conn.setDoOutput(true);
        conn.setRequestMethod("POST");
        conn.addRequestProperty("Content-Type", "application/json");
        conn.addRequestProperty("Accept", "application/json");
        conn.setInstanceFollowRedirects(false);

        int timeoutMillis = timeoutSec * 1000;
        conn.setConnectTimeout(timeoutMillis);
        conn.setReadTimeout(timeoutMillis);
        if (conn.getReadTimeout() != timeoutMillis) {
            System.out.println("Read timeout did not get set on HTTP connection - the JRE uses a broken timeout mechanism - nothing we can do.");
        }

        out = conn.getOutputStream();




        //------------------------------------------------------

        Authenticator passwordAuthenticator = new AS7Authenticator("username","password");
        Authenticator.setDefault(passwordAuthenticator);

        // read system property "as7plugin.verbose"
        Boolean verbose = true;

        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);



        String json_to_send = mapper.writeValueAsString(operation);

        // Check for spaces in the path, which the AS7 server will reject. Log verbose error and
        // generate failure indicator.
        if ((operation != null) && (operation.getAddress() != null) && operation.getAddress().getPath() != null) {
            if (containsSpaces(operation.getAddress().getPath())) {
                Result noResult = new Result();
                String outcome = "- Path '" + operation.getAddress().getPath()
                    + "' is invalid as it contains spaces -";
                if (verbose) {
                    System.out.println(outcome);
                }
                noResult.setFailureDescription(outcome);
                noResult.setOutcome("failure");
                JsonNode invalidPathResult = mapper.valueToTree(noResult);
                System.out.println(invalidPathResult);
            }
        }

        if (verbose) {
            System.out.println("JSON to send: " + json_to_send);
            System.out.println(conn.getInputStream());
        }

        mapper.writeValue(out, operation);

        out.flush();
        out.close();



        InputStream inputStream = (conn.getInputStream() != null) ? conn.getInputStream() : conn.getErrorStream();

        if (inputStream != null) {
            // Note: slurp() will close the stream once it's done slurping it.
            byte[] responseBodyBytes = StreamUtil.slurp(inputStream);

            ByteArrayInputStream arrayInputStream=new ByteArrayInputStream(responseBodyBytes);
            BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(arrayInputStream));

            String responseBody="";
            while (bufferedReader.ready()) {
                responseBody+=bufferedReader.readLine()+"\n";
            }

            String outcome;
            JsonNode operationResult=null;
            if (!responseBody.isEmpty()) {
                outcome = responseBody;
                operationResult = mapper.readTree(outcome);
                if (verbose) {
                    ObjectMapper om2 = new ObjectMapper();
                    om2.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
                    String tmp = om2.writeValueAsString(operationResult);
                    System.out.println(tmp);
                }
            } else {
                System.out.println("Null stream");
            }
            System.out.println(operationResult);

        }

    } catch (IllegalArgumentException iae) {}

}

public static boolean containsSpaces(String path) {
    boolean includesSpaces = false;
    StringTokenizer components = new StringTokenizer(path, " ");
    if (components.countTokens() > 1) {
        includesSpaces = true;
    }
    return includesSpaces;

}

}

STEP 1(uloading) I thought it works fine, it returns success reponse, also says

06:18:37,551 INFO  [org.jboss.as.repository] (HttpManagementService-threads - 6) JBAS014900: Content added at location /servers/jboss-as-7.1.2.Final/standalone/data/content/da/39a3ee5e6b4b0d3255bfef95601890afd80709/content

But this content file is empty!!!

Also when STEP 2(deploying) runs it throws following error

Server returned HTTP response code: 500 for URL: http://localhost:9990/management

In stack trace I have

07:19:35,870 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."jboss-as-numberguess33.war".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."jboss-as-numberguess33.war".STRUCTURE: JBAS018733: Failed to process phase STRUCTURE of deployment "jboss-as-numberguess33.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.2.Final-SNAPSHOT.jar:7.1.2.Final-SNAPSHOT]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_24]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_24]
at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_24]

Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018740: Failed to mount deployment content
at org.jboss.as.server.deployment.module.DeploymentRootMountProcessor.deploy(DeploymentRootMountProcessor.java:92) [jboss-as-server-7.1.2.Final-SNAPSHOT.jar:7.1.2.Final-SNAPSHOT]
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116) [jboss-as-server-7.1.2.Final-SNAPSHOT.jar:7.1.2.Final-SNAPSHOT]
... 5 more
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method) [classes.jar:1.6.0_24]
at java.util.zip.ZipFile.<init>(ZipFile.java:127) [classes.jar:1.6.0_24]
at java.util.zip.ZipFile.<init>(ZipFile.java:144) [classes.jar:1.6.0_24]
at org.jboss.vfs.VFSUtils.unzip(VFSUtils.java:845)
at org.jboss.vfs.VFS.mountZipExpanded(VFS.java:536)
at org.jboss.vfs.VFS.mountZipExpanded(VFS.java:567)
at org.jboss.as.server.deployment.DeploymentMountProvider$Factory$ServerDeploymentRepositoryImpl.mountDeploymentContent(DeploymentMountProvider.java:97) [jboss-as-server-7.1.2.Final-SNAPSHOT.jar:7.1.2.Final-SNAPSHOT]
at org.jboss.as.server.deployment.module.DeploymentRootMountProcessor.deploy(DeploymentRootMountProcessor.java:88) [jboss-as-server-7.1.2.Final-SNAPSHOT.jar:7.1.2.Final-SNAPSHOT]

Please reply if you have any ideas about it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:31:57+00:00Added an answer on June 3, 2026 at 12:31 am

    Depending on what you want to do, this is a multi-step task

    • upload bits to http://localhost:9990/management/add-content
    • register the upload with a name in the server
    • for domain mode promote to server groups.

    We are doing this in RHQ as part of the AS7 plugin
    For the first part, you can have a look at ASUploadConnection. This is triggered from BaseComponent#deployContent, which after a successful upload also runs the next two steps in #runDeploymentMagicOnServer.

    Feel free to copy/re-use that code

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jboss-as-7.1.0.Final-SNAPSHOT and trying to set up custom login module that uses
I have upgrade my MVC2 project to MVC3 using this tool: http://blogs.msdn.com/b/marcinon/archive/2011/01/13/mvc-3-project-upgrade-tool.aspx Which is
We are thinking to use the newly released EF 4.3.x http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx does anybody know
Im using this example as a guide: http://geekswithblogs.net/michelotti/archive/2010/08/21/restful-wcf-services-with-no-svc-file-and-no-config.aspx I've created the site by following
I am using deployjava.js to deploy this applet <script src=http://java.com/js/deployJava.js></script><script> var attributes = {codebase:
I want to deploy some different applications using one jboss (jboss as 7). Can
i created a ws client using wsconsume tool of jboxx 4.2.2 (it's mandatory that
We deploy web services implemented by using the CXF framework on the Glassfish application
Whenever I deploy a production application that has an error with an externalized configuration
I'm trying to deploy my Rails (3.1.3) application to the preprod env. I use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.