AnsweredAssumed Answered

error while programmatically deploying with rest api

Question asked by halilagin on Jul 12, 2012
Latest reply on Jul 12, 2012 by trademak
Hi List,

I am trying to programmatically deploy a bar file to activiti-explorer by the help of rest api provided. I search the net and forum but couldnot find any example.
In the below segment, there are three part:

1. http post sent by restlet api
2. http responce received by the client api
3. the code I wrote wh,ch does not work.

In the code, deploy method is working, but deployInrestlet method does not work. To watch the data sent from the client I used tcpmon program. The main sympthom is that "HTTP/1.1 405 Method Not Allowed". I tested ACTIVITI_REST_URI + "/process-definitions?size=100" address programmatically and  I saw that it works correctly. What could be the problem?


-halil agin.

—————————— http post sent —————————–

POST /activiti-rest/service/deploy HTTP/1.1
Date: Thu, 12 Jul 2012 08:21:37 GMT
Accept: */*
Host: localhost:8111
User-Agent: Restlet-Framework/2.0.0
Authorization: Basic a2VybWl0Omtlcm1pdA==
Content-Length: 78168
Content-Type: multipart/form-data
Last-Modified: Thu, 28 Jun 2012 14:23:05 GMT
Content-Disposition: inline;


—————————— http post sent —————————–

—————————— http response received —————————–
HTTP/1.1 405 Method Not Allowed
Date: Thu, 12 Jul 2012 08:21:37 GMT
Accept-Ranges: bytes
Allow: GET
Server: Restlet-Framework/2.0.8
Content-Type: text/html;charset=UTF-8
Content-Length: 487

   <title>Status page</title>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Method Not Allowed</p>
<p>The method specified in the request is not allowed for the resource identified by the request URI</p>
<p>You can get technical details <a href="">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.

—————————— http response received —————————–

—————————————– code ——————————————————-
private static String ACTIVITI_REST_URI = "http://localhost:8111/activiti-rest/service";
   private static String barFileName = "/home/halil/projects/workspace_btg/activiti-engine-examples/target/";

   public void deploy() {
      try {
         ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(

         RepositoryService repositoryService = (RepositoryService) applicationContext

         String barFileName = "/home/halil/projects/workspace_btg/activiti-engine-examples/target/";
         ZipInputStream inputStream = new ZipInputStream(
               new FileInputStream(barFileName));
          * repositoryService.createDeployment()
          * .name("")
          * .addZipInputStream(inputStream) .deploy();

         final Deployment deployment = repositoryService
         if (deployment == null) {
            final DeploymentBuilder deploymentBuilder = repositoryService

      } catch (Exception ex) {


   public void deployInRestlet() {
      try {

         ClientResource clientResource = new ClientResource(
               ACTIVITI_REST_URI + "/deploy");
               "kermit", "kermit");
         FileResource fileResources = clientResource
         Representation rep = new FileRepresentation(new File(barFileName),
         // Prepare the disposition header with the file name.
         File myzipfile = new File(barFileName);
         Form form = new Form();
         form.add(Disposition.NAME_FILENAME, myzipfile.getName());
         rep.setDisposition(new Disposition(Disposition.TYPE_INLINE, form));

      } catch (Exception ex) {


—————————————– code ——————————————————-