Saturday, December 1, 2007

Glassfish for Tomcat and WebMethods

These recent days I've been played around with Glassfish in my project. I have to build connectivity between our existing Card Management for Telco company product, created with pure jsp (yes, jsp treated as PHP, spaghetti or whatever you name it) to integrate with SAP. Our client provides WebMethods Integration server 6.5 as our only and only way to interact with the SAP. OK then, I grabbed some code from my previous project with Tomcat and WebMethods 6.1 and try to reuse them in this project. Well, it works. But this code only deals with connectivity. Tomcat contacts WebMethods, and that's it. All transaction maintained by WebMethods, no need to think about rollback, commit, or anything, we apply that on WebMethods's flow services. So simple and cool !. But this current project is different. Installed WebMethods dont have any license of JDBC Adapter, it only has SAP Adapter. So in order to save to database or whatever to our Card Management system, we have to build our own connectivity method. Previously we thought about creating Stored Procedure inside our database that later can be invoked by WebMethods's JDBC Adapter, but the client doesnt want to buy the license. Hmm....

Besides just store to database, our Card Management product also have to provide interfaces so that later on, it could synchronize any document with SAP. So SAP will hit our services if..let's say some PO created in SAP. In here, I need to provide them with webservices to access all of our Card Management API in proper way.

On other side, our Card Management also must be able to synchronize any action triggered from our side. Ok, I can use my previous code just to call the WebMethods's service, but I can not predict how long will it take. WebMethods will continue our request to SAP, and then SAP done some process inside, and after that it will returns a value to us. Based on those values, we must done an action, and after we finished done those action in our side, we must push the result back to SAP, send our document number also. I cant imagine how long the users will be wait for these sequence action. They will bury us :D

I see that we can divide this process by synchronous and asynchronous action. There's some action that we need to retrieve the results back from SAP immediately, such as get price. I can't do anything for this action. Saving the price list in our Card Management will blow our mandays. And other process where the users dont care whether they get the result in real time or not. They can check back later to see what happen to their process. So, in here, I need a messaging service.

So, two needs, webservice and messaging. I was thought that I will install a several products for this. Spring webservice framework to make my life easier when creating webservices (their POJO style's are really cool and simple) and ActiveMQ to provide the messaging broker. All can be integrated within our tomcat instance. But,later I also have own more concern. I must not change too many configuration on currently running tomcat instance, since it runs stable right now. And also, user portal and backend integrations are 2 different thing. The users must not feel any 'world wide wait' thing when the backend process works hard to full fill their request. So here I decided to install one more instance of application servers for integration needs. And after some browsing, I decide to install Glassfish V2.

Why glassfish ? well, let's say, first I impressed with it's admin console. JBoss guys should really pay attention on this admin console. And secondly, I fall in love with it's support of WebServices. Glassfish support WebServices monitoring. Here I can monitor who called my webservices, on what time, what data sent, and what data returned. This is very useful when reconcile any lost datas. And the third part is, this Glassfish thing has a great messaging supports based on Sun's IMQ. I also browsed the net for this feature, and many guys out there recommends it. Last but not least, Glassfish V2 is JEE 5 compliance app.server (if not the RI itself). Creating WebServices, session EJB's and MDB's are easier with Annotations. Say good bye to deployment descriptor.

Ok, that's my review, maybe I'll write more about this later.

Tuesday, November 13, 2007

Ruby Install on DSL Linux

Went home earlier than before today, after a day full of meeting with client. I missed my linux. Got a bling about ruby. This stuff sounds cool. Lot's of java programmer migrating to this language, let's give it a shot. I started my adventure by googling with some 'beginner standars' keyword regarding ruby : "howto install ruby", and I got these links :
- http://www.ruby-lang.org/id
- http://hivelogic.com/narrative/articles/ruby_rails_lighttpd_mysql_tiger?status=301
Great, I boot up my DSL linux under qemu, and start downloading the necessary package. I tried to install using DSL's extension facilities (MyDSL-ruby.dsl) but, I don't know if it's work. So I decided to download the source, and compile it, just like the good old days :)
First, I downloaded ruby here. And then as usual, run 3 commands :
dsl@1[ruby-1.8.6]$ ./configure --prefix=/opt/ruby-1.8.6
dsl@1[ruby-1.8.6]$ make
dsl@1[ruby-1.8.6]$ sudo make install
And, I got my ruby installed in /opt/ruby-1.8.6. Dont forget to add the path reference to ruby's bin/ directory installation as follows (mine at /opt/ruby-1.8.6/bin) :
export PATH=/opt/ruby-1.8.6/bin:$PATH
To make my life easier, I put that line in /etc/profile, and run : source /etc/profile. Check whether it points to the right path, type : irb, it should shows you some prompt like this :
dsl@0[Installer]$ irb
irb(main):001:0>

Ok, I continued my journey by getting a tools called RubyGems. This RubyGems is a handy command-line tool for managing the installation of Ruby packages, like Rails ('quoted from here ').
I downloaded it from here.
After that, I unpack it, and went inside the exploded directory and type : ruby setup.rb
This will start the installation process of RubyGems.

OK, next I installed Rails, what is it ?.
Quoted from http://rubyonrails.org/, ruby itself is a programming language, and Rails is the framework, just like Struts in Java. Rails is a full-stack framework for developing database-backed web applications according to the Model-View-Control pattern.

After RubyGems installed, it's all easy to install Rails, I just have to type :
sudo gem install rails --include-dependencies
And RubyGems will download all the needs.

While RubyGems downloading my Rails installation, I went to next step and install PCRE and Lighttpd. PCRE is a Ruby regex extensions stands for Perl Compatible Regular Expression. I downloaded it from here. While Lighttpd is a webserver that became the default one when we choose Rails. I downloaded Lighttpd from here.
First, PCRE. I run : ./configure, make, and make install. I done the same command with Lighttpd, only that I gave different prefix on each ./configure like this :
PCRE : ./configure --prefix=/opt/pcre-7.4
Lighttpd : ./configure --prefix=/opt/Lighttpd-1.4.18
And the rest make and make install commands were same.

Ok, I should be ready for rock and roll with ruby on rails.
I'll write my next experiments later. Now, it's time to get rest, we'll have a great patch deployment tomorrow :)

Sunday, June 3, 2007

Apache Httpd and Tomcat integration using mod_jk, part 2

This posting splitted because somehow blogspot just cut it. I don't know why but when I previewed the posting, blogspot just cut the postings, so I splitted it into 2 parts.

Ok, now we create workers.properties file.
onty@phoenix:/opt/httpd-2.2.4$ vi conf/workers.properties
------------------------------------------------------------------------------------
worker.list=router,jkstatus
# Define a worker using ajp13
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
# Define prefered failover node for worker1
worker.worker1.redirect=worker2
# Define another worker using ajp13
worker.worker2.port=8009
worker.worker2.host=localhost
worker.worker2.type=ajp13
worker.worker2.lbfactor=1

# Define the LB worker
worker.router.type=lb
worker.router.balance_workers=worker1,worker2
# Define the status worker
worker.jkstatus.type=status

------------------------------------------------------------------------------------
This file defines all our workers. Our 'router' worker will be a load balancer worker for other workers, including worker1 and worker2.

Now, we install (unzip, exactly) our apache. We use apache-5.2.23. We will modify the directory structure little bit, as shown like this.


Give attention to tomcat1 and tomcat2 directory, and also directories inside it.We will use 2 instance of tomcat1 and tomcat2 as worker 'worker1' and 'worker2'. We also need to configure each server.xml in tomcat1 and tomcat2 so that they're not using the same port.
Tomcat1 :
Server port="8005" shutdown="SHUTDOWN"
..
..
Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3"
..
..

Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"

Tomcat2 :
Server port="9005" shutdown="SHUTDOWN"
..
..
Connector port="9009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3"
..
..

Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"

One more thing, we need to create startup and shutdown file for each tomcat instance. We call it start1.sh, start2.sh, stop1.sh, stop2.sh
start1.sh
#!/bin/bash
export CATALINA_BASE=/opt/apache-tomcat-5.5.23-cluster/tomcat1
export JAVA_HOME=/opt/jdk1.6.0
./startup.sh
start2.sh
#!/bin/bash
export CATALINA_BASE=/opt/apache-tomcat-5.5.23-cluster/tomcat2
export JAVA_HOME=/opt/jdk1.6.0
./startup.sh
stop1.sh
#!/bin/bash
export CATALINA_BASE=/opt/apache-tomcat-5.5.23-cluster/tomcat1
export JAVA_HOME=/opt/jdk1.6.0
./shutdown.sh
stop2.sh
#!/bin/bash
export CATALINA_BASE=/opt/apache-tomcat-5.5.23-cluster/tomcat2
export JAVA_HOME=/opt/jdk1.6.0
./shutdown.sh

Basically, these file just aimed to setup environment variable named CATALINA_BASE to point which tomcat instance we want to start/stop.

Now, lets try our installation. Start both tomcat instance, and also start your httpd server. Point out the browser to http://localhost/tomcat-docs/ and see if the request handled correctly. Httpd will redirect the request so that can be served by tomcat. Also point the browser to http://localhost/jkmanager/. This context path shows us the Load Balancing status for our tomcat instance.

Feel free to drop any comments about this posting.
Thanks, good luck trying !

Apache Httpd and Tomcat integration using mod_jk, part 1

In my other blog, I've wrote about howto use mod_jk2 to integrate httpd and tomcat. The article can be accesed here and here.
Now, since mod_jk2 has not supported again by apache-tomcat-connector developers, so in this article I will use mod_jk. I'm using :
  • httpd-2.2.4, can be downloaded here
  • tomcat-5.2.23, can be downloaded here
  • tomcat-connector, can be downloaded here

I prefer apache.the.net.id since this is the nearest mirror from Indonesia. O ya, Im using Kubuntu Feisty Fawn in my laptop.
First, we install the httpd-2.2.4 first. Unzip it, place it at some directory you like. In my environment, my user has full access to /opt directory, so I'm using it.
onty@phoenix:/opt$ gunzip httpd-2.2.4.tar.gz
onty@phoenix:/opt$ tar -xvf httpd-2.2.4.tar
onty@phoenix:/opt$ mv httpd-2.2.4 httpd-2.2.4-src
onty@phoenix:/opt$ cd httpd-2.2.4-src
Configure, put the result in /opt/httpd-2.2.4, enable shared object, enable cgi support. Enabling shared object makes us able to load dynamic shared object library. We're using mod_jk's shared object, so we need to enable apache to support dynamic shared object library. This also usefull if you want to enable your apache httpd server to serve PHP also. Same like this, you would also compile PHP as shared object, and then load it dynamically to apache httpd using LoadModule syntax in your httpd.conf .
onty@phoenix:/opt/httpd-2.2.4-src$ ./configure --prefix=/opt/httpd-2.2.4 --enable-so --enable-cgi
onty@phoenix:/opt/httpd-2.2.4-src$ make onty@phoenix:/opt/httpd-2.2.4-src$ make install
Now, try to start it using root :
onty@phoenix:/opt/httpd-2.2.4-src$ cd /opt/httpd-2.2.4
onty@phoenix:/opt/httpd-2.2.4$ su -
root@phoenix:/opt/httpd-2.2.4# bin/apachectl start
If everything ok, you should be able to point your browser to http://localhost now, and see if you can read any "It works" there.
OK, now we continue to install the tomcat connector. Apache has provided us with the binary version of the connector. As mentioned in before, we should now already download it. I'm using mod_jk-1.2.21-apache-2.2.x-linux-i686.so. What we need to do is just load this shared object so that can be used by apache, that simple ? yes :D
Edit your httpd.conf, add this line :
Include conf/extra/mod_jk.conf
This is new style from apache that makes us easier to maintain our configuration file in modular basis.
Now create a new file in conf/extra/ name it mod_jk.conf.
--------------------------------------------- mod_jk.conf -----------------------------------
JkWorkersFile /opt/httpd-2.2.4/conf/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm

JkLogFile /opt/httpd-2.2.4/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkMount /tomcat-docs/* router

JkMount jkstatus
Order deny,allow
Deny from all
Allow from 127.0.0.1

-------------------------------------------------------
From the configuration file, we can see that :
We will place the log file in /opt/httpd-2.2.4/logs/mod_jk.log.
We will configure the connectors with a file named workers.properties located in /opt/httpd-2.2.4/conf .
We will have shared file that will be used by apache and tomcat, located in /var/log/httpd/mod_jk.shm. If the directory /var/log/httpd doesnt exist yet, we should create it first using root user.
The logger level will be INFO.
We will map /tomcat-docs/ request in httpd to be handled by tomcat, so make sure that this webapp exist in tomcat. By default if you download tomcat, this webapp is already exist. Later you can change it to your own webapp. And this request will be handled by a worker named 'router'.
Last one is for jkmanager monitoring tools. There will be new context path named /jkmanager/ that will show us status for our jk_module. This context path only allowed to be accessed from 127.0.0.1 (localhost).

Ok, now we need to create workers.properties in conf/ directory. See part 2 of this post.

Friday, June 1, 2007

Tora(Toolkit for Oracle) Installation

Yesterday I managed to install my laptop with Tora. I'm using Kubuntu Feisty Fawn.For you who doesnt have any idea what kind of animal Tora is, let me give you some hint. If you used to use Toad in M$-Windows to do your oracle database-related jobs, well, you can say that Tora has similar usage.It can runs on Linux, make your life simpler, and easier, he he. Hey, it's your laptop that should work for you, not you're the one that has to work for your laptop, right ?
Ok, here's the step I saved from my installation adventure :

1. get Oracle instant client
You can get it here :
http://download.oracle.com/otn/linux/instantclient/instantclient-basic-linux32-10.2.0.3-20061115.zip
http://download.oracle.com/otn/linux/instantclient/instantclient-sdk-linux32-10.2.0.3-20061115.zip

2. Unzip it at some directory, e.g : /opt/instantclient_10_2

3. Add the directory to /etc/ld.so.conf, dont forget run /sbin/ldconfig.
Here's the sample from my laptop :
------------------
onty@phoenix:~$ cat /etc/ld.so.conf
/lib
/usr/lib
/usr/lib/firefox/plugins
/opt/instantclient_10_2
------------------

4. Install libqscintilla.
Thank God, I'm using Kubuntu,and having great internet connection in my office. So just simply run apt-get.
root@phoenix:/opt# apt-get install libqscintilla6 libqscintilla-dev

5. Download and Unzip tora
You can get it here. I'm using version 1.3.21.

6. compile start
oracle@phoenix:/opt/tora-1.3.21$ ./configure --with-qt-dir=/usr/lib/qt3 --with-oracle-libraries=/opt/instantclient_10_2 --with-oracle-includes=/opt/instantclient_10_2/sdk/include --with-oci-version=10G --with-instant-client
oracle@phoenix:/opt/tora-1.3.21$ make
oracle@phoenix:/opt/tora-1.3.21$ make install

7. In the midde of make, I'm getting error says that toThreadStartWrapper has not been declared. I googled around to find the solution, and found out that I have to edit a file named tothread.cpp around line 157 like below.

#define THREAD_ASSERT(x) if((x)!=0) { \
throw (qApp->translate("toThread","Thread function \"%1\" failed.").arg(QString::fromLatin1( #x ))); }

/* new added start */
void *toThreadStartWrapper(void *t);
/* new added end */

void toThread::initAttr()

After that, I continued with make, and make install.

And finally, run ./tora and you can see ORACLE option in your connection. That connection refers to wherever you put our TNSNAMES.ORA in your ORACLE_HOME.


OK, that's for today's tip.

Tuesday, May 29, 2007

Testing my new Blog

This is just write test for the first time using blogspot.com, this is the second blog I have. My first one is in http://www.jroller.com/page/JPrasojo . I just want to try out google's owned blog space. Let's see how good it woks.