cancel
Showing results for 
Search instead for 
Did you mean: 

RESTful webservices Fail

carmoca
Champ in-the-making
Champ in-the-making
Thank you for reviewing my post. I'll get straight to the point.

I've tried this on three different installs/OSes:
Ubuntu 12.04lts (VM) (via Win7/VirtualBox)
Ubuntu 11.10    (VM) (via Win7/VirtualBox)
Ubuntu 12.04lts (baremetal)

System lineup for each install is as follows:
Activiti 5.11 (binary-That is, I did not build it.)
H2 DB (h2-1.3.170.jar)
Apache TOMCAT 7.0.34
JAVA 7 (openjdk1.7.0_09)
ANT 1.8.4 (Though I've not directly needed it)
NETBEANS 7.2.1
SOAP UI 4.5.1

System Configuration:
I've extracted all the above to my home folder.

TOMCAT Config:
I added the role "manager-gui" and user "tomcat" with a role and a password to the TOMCAT config.
I copied the 'activiti-explorer.war' and 'activiti-rest.war' files (both manually and using the TOMCAT manager's "deploy" interface). Both methods yield the same webservice-result (discussed below).  After seeing that the activiti-explorer is running and activiti-rest webservice are NOT running (via TOMCAT /MANAGER page), I start the H2 DB.  THen validate that activiti-rest is running,

It's worth mentioning that I've also started the H2 DB first and THEN started TOMCAT; yet, I still get the same webservice-result (discussed below).

I open the Activiti-Explorer website and start the 'Vacation Request' process.  I fill in the form with a few days and a date as the form requires.  I then start the process and switch to the TASKs viewer to validate the process is started.

/home/virtualme/apache-tomcat-7.0.34/webapps/activiti-explorer/WEB-INF/activiti-standalone-context.xml War file (partial) config:


   …
  <!– This Spring config file is NOT used in Alfresco, as the Activiti engine is wired in a different way there –>
      
  <bean id="demoDataGenerator" class="org.activiti.explorer.demo.DemoDataGenerator" init-method="init">
    <property name="processEngine" ref="processEngine" />
    <property name="createDemoUsersAndGroups" value="true" />
    <property name="createDemoProcessDefinitions" value="true" />
    <property name="createDemoModels" value="true" />
  </bean>
 
  <bean id="dbProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:db.properties" />
    <!– Allow other PropertyPlaceholderConfigurer to run as well –>
    <property name="ignoreUnresolvablePlaceholders" value="true" />
  </bean>
   
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="${jdbc.driver}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="defaultAutoCommit" value="false" />
  </bean>

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
     <property name="dataSource" ref="dataSource" />
  </bean>
   …

H2 DB WEBINF config:

db=h2
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:tcp://localhost/activiti
jdbc.username=sa
jdbc.password=

Here's my start sequence:
sh startws.sh

./apache-tomcat-7.0.34/bin/startup.sh
nohup java -jar h2/bin/h2-1.3.170.jar &
or

nohup java -jar h2/bin/h2-1.3.170.jar &
./apache-tomcat-7.0.34/bin/startup.sh

H2 Database comes up on 127.0.1.1:8082 MOST of the time - if not ALL the time.


The code I've written on my PC *does* work on my friend's PC - and even returns a viewable JSON object tree.  However, when run on either of the three (3) machines I've created for this specific task I get bumkiss.  The libraries for the quickstart project include: http://www.trieuvan.com/apache//httpcomponents/httpclient/binary/httpcomponents-client-4.2.2-bin.tar...


package quickstart;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import sun.misc.BASE64Encoder;

public class QuickStart {

    public static void main(String[] args) throws Exception {
    StringBuffer output = new StringBuffer();

    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpGet getRequest = new HttpGet("http://127.0.1.1:8082/activiti-rest/service/process-instances");
    //HttpGet getRequest = new HttpGet("http://127.0.1.1:8082/activiti-rest/service/process-definitions");

    BASE64Encoder encoder = new BASE64Encoder();
    String encodedUserPass = encoder.encode("kermit:kermit".getBytes());
    getRequest.addHeader("Authorization", "Basic " + encodedUserPass);

    HttpResponse response = httpClient.execute(getRequest);
   
    System.out.println (response.toString());
       
    if (response.getStatusLine().getStatusCode() != 200) {
    // URL Not found
    } else {
        BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        String responseText;
        while ((responseText = br.readLine()) != null) { //This hits every time.
            output.append(responseText); //This line NEVER hit on my machines,
        }
       
        System.out.println("output contents begin: \n" + output.toString() + "\n\noutput contents end");
    }
    try {
            System.out.println(response.getStatusLine().toString());
                      
        } finally {
            getRequest.releaseConnection();
        }
    }
}

Output of application

Have no file for /usr/lib/jvm/java-7-openjdk-i386/jre/lib/netx.jar
Have no file for /usr/lib/jvm/java-7-openjdk-i386/jre/lib/plugin.jar
Have no file for /usr/lib/jvm/java-7-openjdk-i386/jre/lib/jfr.jar
HTTP/1.1 200 OK [Content-Type: application/octet-stream, Cache-Control: max-age=10, Last-Modified: Tue, 8 Jan 2013 21:27:59 GMT, Content-Length: 0]
output contents begin:


output contents end
HTTP/1.1 200 OK
BUILD SUCCESSFUL (total time: 9 seconds)

So, the basic question is: What am I doing wrong that I can get 'http 1.1 200 ok' messages but I get no JSON objects - or rather, Why does it seem that activiti-rest is not functioning as expected?

Thank you, in advance!
1 REPLY 1

klimperos
Champ in-the-making
Champ in-the-making
Hi carmoca,

A few things you might consider:

(a) Merge  Activiti REST and Activiti Explorer into a single WAR file and try again.
See: http://forums.activiti.org/en/viewtopic.php?f=9&t=2386

(b) Double check your REST call results using RESTClient: https://addons.mozilla.org/en-us/firefox/addon/restclient/
or similar tool for your browser, to rule out any problem with your client.

Regards,
Kevin