Tuesday, July 7, 2009

SVG string inline with HTML

Have you ever wondered how to display the SVG string that you have generated from your program, inline with HTML. I did try this and searched for a lot, but could not find a proper solution. Instead of that, I was redirected to some JavaScript libraries which are used to generate SVG.

If I clearly mention the problem again; There is a SVG as a string, if it is included in a div element it will not be displayed. But if it is saved in a file with the extension ".svg" and open it with FireFox browser, it is displayed correctly.

If the above paragraph mentions the problem you got, then this is the exact place where you get the exact solution :D

Say, there is a div element with the id "svg", then the following JavaScript function can be used to obtain your objective.


drawSVG = function(svgStr) {
var parser = new DOMParser();
var dom = parser.parseFromString(svgStr, "text/xml");
document.getElementById('svg').appendChild(dom.documentElement);
}

It is very simple solution, but it took sometime to reach for the solution.

Apache Batik can be used to generate SVG

Tuesday, June 30, 2009

Deploy Intalio Tempo in Apache Tomcat 5

Now you can try WSO2 BPS 2.0.0 which offers you to deploy human tasks written in WS-HumaTasks standard as well as Business  Processes written in WS-BPEL standard. You can also integrate human tasks within the business  processes according to WS-BPEL4People standard. You can start the server as a stand-alone server, so that no need to go through hard configuration stuff. WSO2 BPS 2.0.0 is open source product. Check release note

Recently, I tried to deploy Intalio Tempo in standalone Apache Tomcat 5.5.xx. Tempo provides a ruby build script (tempo_builder.rb) to provide a Tempo integrated in to a Apache Tomcat server. But, what I required was different scenario. I needed to deploy Tempo in my own Tomcat server.
It took few days for me to deploy Tempo in a standalone Tomcat server. Therefore, I thought of sharing the experience I gained, in-order to minimise the pain of people who are in need of deploying Tempo in Tomcat.
Please note well, this document may not be the best way to deploy Tempo in Tomcat. Therefore, please let me know, if you got to know a better way.

First of all, make sure that all the required software are properly installed. Refer INSTALL.txt to find the required software. If you intend to build Apache ODE, then you have to aware about the Buildr and the Java version. In case if you need help on this, refer this post. Make sure that you install the Buildr version 1.3.3 instead of 1.3.2 to support both ODE and Tempo.

checkout the source of Tempo
git clone git://github.com/intalio/tempo.git

Build the Tempo (according to the building instructions of Tempo )
buildr package

In case, if you have installed Buildr in both Ruby and jRuby, make sure to prefix jruby -S or ruby -S to select between the installed Buildrs.

Build the Tempo (to build the dependency jars, BPEL processes and axis2 services)
run the script TEMPO_CHECKOUT/rsc/scripts/tempo_builder.rb
refer INSTALL.txt for further details

From this onwards:
TEMPO_TOMCAT refers to the Tomcat directory created by the tempo_builder.rb script.
TOMCAT_HOME refers to the standalone Tomcat server in which Tempo should be deployed.

Copy the following
TEMPO_TOMCAT/bin/setenv.sh to TOMCAT_HOME/bin
TEMPO_TOMCAT/var to TOMCAT_HOME/

Edit TOMCAT_HOME/conf/context.xml and add the following in to the <context> element
<resourcelink global="jdbc/BPMSDB" name="jdbc/BPMSDB" type="javax.sql.DataSource"/>
<resourcelink global="DeployRegistry" name="registry/DeployRegistry" type="org.intalio.deploy.registry.Registry"/>
<transaction factory="">TomcatGeronimoTxFactory" />

Edit TOMCAT_HOME/conf/server.xml and add the following to the <globalnamingresources> element
<resource name="jdbc/BPMSDB" auth="Container" type="javax.sql.DataSource" maxactive="100" maxidle="30" maxwait="10000" username="root" password="password" driverclassname="jdbc.Driver" url="jdbc:mysql://localhost:3306/bpms?relaxAutoCommit=true"/>
<resource name="registry/DeployRegistry" auth="Container" type="registry.Registry" factory="org.intalio.deploy.registry.RegistryObjectFactory" />

Edit TOMCAT_HOME/conf/web.xml and add the following to the element <web-app>
<resource-ref>
<res-ref-name>jdbc/BPMSDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

Install MySQL Server and create the database "bpms" and create the schema as in TEMPO_TOMCAT/bpms.sql
create database bpms;
use bpms;
source TEMPO_HOME/bpms.sql;


Copy the MySQL connector jar to TOMCAT_HOME/common/lib

Copy the additional jars in the TEMPO_TOMCAT/common/lib to the TOMCAT_HOME/common/lib
deploy-registry-1.0.3.jar
slf4j-api-1.4.3.jar
slf4j-log4j12-1.4.3.jar
log4j-1.2.15.jar

Deploy Axis2 (1.4.1) and ODE (1.3.2) in your standalone Tomcat Server

Deploy the following web services which are in the TEMPO_CHECKOUT's respective target directories, in Axis2.
tempo-tas-service-5.x.x.x.aar
tempo-tms-service-5.x.x.x.aar

Also deploy the following web services which can be found in TEMPO_TOMCAT/webapps/axis2/WEB-INF/
servicesdeploy-ws-service-1.0.3.aar
security-ws-service-1.0.1.aar

Copy the following jars in TEMPO_TOMCAT/webapps/ode/WEB-INF/lib to the TOMCAT_HOME/webapps/ode/WEB-INF/lib
deploy-api-1.0.3.jar
ode-ext-deploy-1.0.0.jar
tempo-processes-xpath-extensions-6.0.6.jar

Then deploy the following .war files that can be found in respective target directories of TEMPO_CHECKOUT directory.
fds.war
ui-fw.war
wds.war

Then Deploy the xFormsManager.war. It is possible to build it from the source (git clone git://http://github.com/intalio/xforms-manager.git) or download the war file

Now you are ready to use Tempo in your Tomcat server. Please feel free to point out the mistakes in this post as well as your problems regarding deployment.

References:
Tempo-div thread - Is it possible to deploy tempo on tomcat 5.5 and use its runtime
Tempo Installation Guide - INSTALL.txt
Tempo Building Guide - Building
Install Buildr - Buildr for ODE and Tempo
Tempo-div thread which I used to get help - Problem on deploying fds & ui-fw

Saturday, June 27, 2009

Building Apache ODE

I found it little bit hard to build Apache ODE for the first time. I followed the steps in the Building ODE guide as it is. But I was not able to build the ODE source. The appeared error was

Permission denied - Permission denied - /tmp/axis2-adb-1.4.1.jar.16179.53314 or /home/.../.m2/repository/org/apache/axis2/axis2-adb/1.4.1/axis2-adb-1.4.1.jar
Buildr aborted!
Failed to download org.apache.axis2:axis2-adb:jar:1.4.1, tried the following repositories:
http://pxe.intalio.org/public/maven2/
http://people.apache.org/repo/m2-incubating-repository/
http://repo1.maven.org/maven2/
http://people.apache.org/repo/m2-snapshot-repository/
http://download.java.net/maven/2/
http://ws.zones.apache.org/repository2/

(Note well, this error only appears, if you build the ODE for the first time or build it with a cleaned repository.)
Therefore, I tried my best to grant the permission to the relevant directories, but, it did not help. I tried to build it as a super user, then it worked. But, it will not help because all the dependencies are copied to the root's .m2 repository.

Actually there was not a single clue to find the fault. After trying out several tests, I was able to figure out that the root cause is the version of the Apache Buildr. Let me explain in detail, how I installed Buildr.

Installing Apache Buildr in jRuby
First of all I downloaded the jRuby 1.2.0. After following the steps in the Guide, I use the following command to install Apache Buildr in jRuby.

jruby -S gem install buildr

The above command installed the Buildr version 1.3.4 which caused me immense trouble. To solve the problem, I uninstalled the Buildr version 1.3.4 using the command:

jruby -S gem uninstall buildr -v 1.3.4

Then re-installed the older version 1.3.2 again, which relieved me a lot. I still could not figure out the exact wrong with the Buildr version 1.3.4, even though, I posted about the problem in the Buildr dev mailing list. Finally I made my mind by assuming it was a bug in Buildr version 1.3.4. This is a serious because the Buildr version 1.3.4 is not backword compatible :(

There is another important fact about installing Buildr in jRuby instead of Ruby. Quoting Apache ODE Building Guide,

Note that for now, even though ODE can run on JDK 1.6.x, building ODE only works with JDK 1.5.x. So before building, make sure you JAVA_HOME points to a JDK 1.5.x installation

The above statement valid only when using Buildr which installed in Ruby. If You installed the Buildr in jRuby, JDK 1.6.x can be used to build ODE.

Happy ODEing...

Wednesday, June 24, 2009

Sign in to yahoo by PIDGIN

These days Pidgin does not allow to connect to yahoo. It is due to some maintenance or upgrade of their servers. This is a really annoying experience to pidgin-yahoo users. The simple solution is to upgrade the Pidgin version to 2.5.7 (newest). the instructions are given in the pidgin site.

Tuesday, June 9, 2009

Disk Partition strategy for Ubuntu

A newie-bee to Ubuntu may tend to install it in to a single partion ("/"). But it is always advisable to create few more partitions in order make our lives easier, when it is required to re-install Ubuntu as well as when you required to retain the user accounts, their configuration and the softwares insatalled.
In order to achive this, it is required to create atleast another home partition ("/home"). According to the interest, a "/opt" partion can be created in order to install softwares.
Say, You have to re-install Ubuntu due to a inevitable reason, then it is only require to format the root ("/") partion only, other partions can be left intact. You required to create the same user accounts to activate the old user accounts.
In this way, it is possible to re-install Ubuntu without wasting much to configure it again.

Saturday, May 23, 2009

Configure SSH to connect without entering password

This blog post is not about hacking into another's machine without the proper authorization of the owner. If you are looking for that, this is not the right place.

This is about configuring the SSH without entering the password, but, with the proper authorisation of the machine owner :). In cluster computing quite often, it is required to do this. This article describes how to do it by using "DSA" encryption algorithm. It is quite possible to use "RSA" encryption too.

Say there are two machines called A and B. Now we are going to configure machine A to connect to machine B without entering the password of machine B.

Generate private and public keys for the machine A.
ssh-keygen -t dsa

The ssh-keygen command will ask you to enter a passphrase. In this case it should be empty in order to connect without entering a password to the machine B.

The above command will place the private key file (id_dsa) and the public key file (id_dsa.pub) in the ".ssh" directory in the home directory of your user account.
Then copy the public key of machine A to the ".ssh/authorized_keys" file resides in the home directory of the machine B.

Now, you can connect to the ssh server of machine B from machine A without entering a password/passphrase.
In a cluster environment, you have to configure ssh in such a way that it enables to connect each others' ssh servers.

NOTE: It is not recommended to leave a passphrase empty when creating the keys. But, for the situations like clusters who comunicates via ssh, passphrase should be kept empty.

Get MySQL Cluster data nodes started after an unexpected shutdown

This article relates to MySQL version 5.1 and NDB Cluster version 6.x

When you are new to the MySQL Cluster, quite frequently, you face to the the problem of getting the data nodes attached to the cluster. Although some data nodes are started using the ndbd command, the management console shows it as disconnected. You know that there cannot be any configuration problms/errors, because you have started the cluster successfully few hours ago or the previous attempt.
In this kind of situation, most of the time, the root cause of the problem is that the cluster was ended in a improper way, in the previous time. The simple solution is starting the data nodes with the --initial option.

ndbd --initial

Reference: MySQL documentation