Saturday, 12 April 2008
Glassfish and Blojsom3
« India Outsourcing vs. India Education | Main | All dilbert strips available online »While restoring the server one of the things missing was to get my blojsom up and running again. Earlier it was running on Tomcat, but this time, I had already moved most of the other older Tomcat applications to run on Glassfish, so why not Blojsom3 aswell. I found only one earlier article on using blojsom with Glassfish, and it was a rather old article, describing Blojsom 2.x. So, here goes...
Download blojsom.war
First, you have to download the blojsom.war
(or, download from your favorite SourceForge mirror here). Then unpack it to some directory:wget http://switch.dl.sourceforge.net/sourceforge/blojsom/blojsom.war
mkdir blojsominst; ( cd blojsominst; unzip ../blojsom.war )
2. Load blojsom defaults into a Derby database
We're going to use an embedded derby database inside Glassfish, but before we configure the connectionpool and datasource there, we're going to create it and load the Blojsom data into it. This is because how the embedded Derby database works, it will be locked if we already configure Glassfish to connect to it. Also, as you might notice, we're going to update the URLs to be localhost:8080 since for some reason someone put some insane hostname in the Derby defaults :-)
export DERBY_HOME=$GLASSFISH_HOME/javadb
$DERBY_HOME/bin/ij <<__EOF__
connect 'jdbc:derby:$GLASSFISH_HOME/lib/databases/Blojsom3;create=true;user=blojsom;password=blojsom';
run 'blojsominst/WEB-INF/classes/blojsom-full-initial-data-derby-embedded.sql';
update Properties set PROPERTY_VALUE = 'http://localhost:8080/blojsom' where PROPERTY_NAME in ('blog-base-url');
__EOF__
3. Create a datasource for blojsom to use.
I use the embedded derby database, so we dont need to install anything additional to get up and running. Just fire the commands as follows:
asadmin create-jdbc-connection-pool \
--datasourceclassname org.apache.derby.jdbc.EmbeddedDataSource \
--restype javax.sql.DataSource \
--property User=blojsom:Password=blojsom:DatabaseName=\$\{com.sun.aas.instanceRoot\}/lib/databases/Blojsom3:ConnectionAttributes=create\\=true \
Blojsom3Pool
asadmin create-jdbc-resource \
--connectionpoolid Blojsom3Pool Blojsom3DS
asadmin ping-connection-pool Blojsom3Pool
You can also do it from your console ofcause. If all is good, it should show you something like:
"Command ping-connection-pool executed successfully."
4. Configure blojsom.war and deploy it.
Now, we just need to modify blojsom configuration to use the embedded Derby instead of the "normal" MySQL that it comes with per default.
For this I have created a patch for the blojsom-helper-beans-include.xml to work with the Derby DataSource, which you can apply like this:
wget http://tanesha.net/bigmess/patch.blojsom-helper-beans-include.txt ( cd blojsominst; patch -p0 < ../patch.blojsom-helper-beans-include.txt; zip -r ../blojsom.war * )
Then just deploy it :-)
asadmin deploy --upload=true ./blojsom.war
Finally go to your http://localhost:8080/blojsom/blog/default?flavor=admin and login with default/default and configure the rest of your blog settings.
[Trackback URL for this entry]
