Couple of weeks back JBoss Stormgrind project created an AMI (ami-0cda3165) for GateIn 3.1.0.Final . If you have created an Amazon's EC2 instance from existing AMI before, creating a GateIn EC2 instance is no different. When an instance is running, you can access the default portal at URL which will look something like http://ec2-75-101-229-18.compute-1.amazonaws.com:8080/portal/ Don't try accessing the URL, it will go to /dev/null ;-) If you ssh into your instance, you can see JBoss+GateIn bundle at /opt/gatein-3.1.0.FINAL. By default, GateIn comes bundled with HSQLDB but normally people have a separate instance of DB such as MySQL running on separate server so here I am going to show you how you can configure Amazon RDS aka MySQL 5.1 with your GateIn instance running in cloud.
1. In AWS management console, search for Gatein or you can directly enter ami-0cda3165. In subsequent window pick your availability zone and select instance type as "Small" which is enough to use GateIn for smaller use case and lighter load. Then select your key-pair, security group. Make sure your security group has port 8080 turned on. Ultimately, the details of instance should look similar to following screenshot:
2. Launch your instance and when AWS console says instance is running, you should be able to access the GateIn's landing page at http://ec2-75-101-229-18.compute-1.amazonaws.com:8080/portal/ This verifies that we have GateIn AMI working properly which is running atop HSQL.
3. Now, let's create a RDS instance. Launch DB instance wizard under Amazon RDS tab, select instance class as small, size 5G, give a name to your DB instance (this is not the schema name in case you are wondering) e.g. gateinmysql and of course master userid and password. In next window of wizard, give a DB name which is schema name. For availability zone, select the same zone you selected in step 1. This means that both GateIn and DB servers are collocated which will give you a better network QoS. Your configuration should look something like following:
Launch the DB, go get a cup of coffee because it takes a while for Amazon to launch a DB instance. When it's runnig, your DB server name should look like gateinmysql.ck0mw2jbysdo.us-east-1.rds.amazonaws.com
4. Now we need to hook 1 & 3 together. For this, let's ssh into the GateIn instance and stop GateIn server. We then modify the file, /opt/gatein-3.1.0.FINAL/server/default/conf/gatein/configuration.properties with the details from screenshot in 3. You can see complete detail of configuring GateIn with MySql at GateIn 3.1 reference guide.
5. Copy (scp or wget) MySQL jdbc driver to /opt/gatein-3.1.0.FINAL/server/default/lib
6. Delete data, log, tmp, work folders from /opt/gatein-3.1.0.FINAL/server/default so that we have a clean server again.
7. Start GateIn server by doing "bash run.sh -c default -b 0.0.0.0". After couple of minutes depending on how good network connection between GateIn & RDS is, you should be able to see your portal running again at the URL you saw in 2. You can also use mysql-administrator in your laptop/desktop to see the tables and data GateIn created during startup.
Unless you are a zombie, you would not want to repeat this process every time you need to run GateIn with RDS. You should create your own GateIn AMI based on all modifications you have done. The feature I liked about RDS is that you can take a snapshot of database and relaunch again. Amazon preserves the RDS public server name which means that configuration changes that you made on 4 would continue to work.
Please let me know if you run into any problem when you to try to do yourself and I will update this blog accordingly. Happy clouding and portaling.
-----------------
Help me in my mission at http://www.eejot.org
An effort to rationalize events happening around us - mostly software engineering !!
Tuesday, September 21, 2010
Sunday, September 12, 2010
How to debug a portlet in GateIn !!
Lately I have seen few questions on how to use an IDE to develop and debug a portlet in GateIn user forum. The simplest answer is: it's similar to how you develop and debug a regular (jsp, servlet, jsf etc) web application. But I am going to walk you through one example of doing the same using plain Eclipse (or JBoss Tools ) and GateIn Portal using remote debugging of the upcoming Jasper portlet that is still a work in progress.
Nothing much to add here..it's like any standard java project. You can see further details for creating a new project at http://docs.jboss.org/tools/whatsnew/portlet/portlet-news-1.0.0.Alpha1.html In this example, I am going to import the mavenized jasper project from http://anonsvn.jboss.org/repos/qa/people/vrockai/jasper-sample-portlet/
2. Deploy the portlet into GateIn
Since this is a maven project, doing a maven install will create a .war file which we will deploy or copy to $GATEIN_HOME/server/default/deploy.
3. Preapre GateIn for debugging
Uncomment JPDA section for remote socket debugging in $GATEIN_HOME/bin/run.conf
Please note the port number here. You can change it if you have any conflict on that port.
4. Start GateIn
You simply do "bash run.sh" on Linux/Unix or run.bat on Windows.
5. Hook up Eclipse with GateIn server
In eclipse, select Run->Debug Configurations->Remote Java application and click on "New Launch Configuration Icon" which should show the following screen. Please change the port number from Step 3.
Click Debug. You should not get an error if eclipse is able to connect to the socket on port 8787.
6. Add portlet to a page
As of GateIn 3.1.0, there is no "simple" way of adding a portlet to a page using XML similar to how it was in JBoss Portal so we are going to use GateIn's user interface to do that. You can see how to do that at http://docs.jboss.com/gatein/portal/3.1.0-FINAL/user-guide/en-US/html_single/index.html#chap-User_Guide-Portal_Administration Please ask in user forum if you need help with this. In my case, I added this to home page. I can see the portlet when I visit the home page. However since we did not put any break point, eclispe does not care at this point
7. Add a break point
I am going to add a break point on the first line of code in doView method of JasperPortlet class knowing that this method is always going to be called for normal viewing of this portlet.
8. See it in action
Let's refresh the page which should call doView method again and eclipse should prompt me to go to Debug perspective. Here is screenshot.
Happy debugging.
------------------
Please help me in my effort of computer literacy in Nepal at http://www.eejot.org
1. Import or create a project in eclipse
Nothing much to add here..it's like any standard java project. You can see further details for creating a new project at http://docs.jboss.org/tools/whatsnew/portlet/portlet-news-1.0.0.Alpha1.html In this example, I am going to import the mavenized jasper project from http://anonsvn.jboss.org/repos/qa/people/vrockai/jasper-sample-portlet/
2. Deploy the portlet into GateIn
Since this is a maven project, doing a maven install will create a .war file which we will deploy or copy to $GATEIN_HOME/server/default/deploy.
3. Preapre GateIn for debugging
Uncomment JPDA section for remote socket debugging in $GATEIN_HOME/bin/run.conf
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket, address=8787, server=y,suspend=n"
Please note the port number here. You can change it if you have any conflict on that port.
4. Start GateIn
You simply do "bash run.sh" on Linux/Unix or run.bat on Windows.
5. Hook up Eclipse with GateIn server
In eclipse, select Run->Debug Configurations->Remote Java application and click on "New Launch Configuration Icon" which should show the following screen. Please change the port number from Step 3.
Click Debug. You should not get an error if eclipse is able to connect to the socket on port 8787.
6. Add portlet to a page
As of GateIn 3.1.0, there is no "simple" way of adding a portlet to a page using XML similar to how it was in JBoss Portal so we are going to use GateIn's user interface to do that. You can see how to do that at http://docs.jboss.com/gatein/portal/3.1.0-FINAL/user-guide/en-US/html_single/index.html#chap-User_Guide-Portal_Administration Please ask in user forum if you need help with this. In my case, I added this to home page. I can see the portlet when I visit the home page. However since we did not put any break point, eclispe does not care at this point
7. Add a break point
I am going to add a break point on the first line of code in doView method of JasperPortlet class knowing that this method is always going to be called for normal viewing of this portlet.
8. See it in action
Let's refresh the page which should call doView method again and eclipse should prompt me to go to Debug perspective. Here is screenshot.
Happy debugging.
------------------
Please help me in my effort of computer literacy in Nepal at http://www.eejot.org
Subscribe to:
Posts (Atom)