The Answer to Life, the Universe, and Everything

Sunday, December 09, 2007

Maven2 deploy to other server

Create file settings.xml under .m2
<?xml version='1.0' encoding='utf-8' ?>
<privateKey>C:\Program Files\PuTTY\auth\id_rsa</privateKey>

Then add the following to pom.xml

maven2 java version

You might need to specify the compile java version by using generics etc in pom.xml file.


Saturday, December 01, 2007

Eclipse3.3.1 OutOfMemory

Eclipse 3.3.1 has bug on memory part.

Edit the "eclipse.ini" to fix the issue.

Maven + Eclipse = Error?

If you face the something like the following error,
Unbound classpath variable: ‘M2_REPO/bouncycastle/bcmail-jdk14/132/bcmail-jdk14-132.jar

Select the Eclipse Project folder from the Navigator window view
Right Click and get the Project Properties.
Select the tree item named “Java Build Path”
Push the button on the Right that says Add Variables.
Then Push the button that says Configure Variables.
Then push the New button
Add a new variable named M2_REPO and map it to the directory that contains the repository above.
Exit back to the “New Variable Classpath entry” dialog.
Select the M2_REPO variable and click extend
Select a jar file and exit.

Maven2 : Adding jar to local repos

This is how you can add the Non globally installed jar to your local repos.
mvn install:install-file -DgroupId=<<$Group Name>> -DartifactId=<<$Project Name>> \
-Dversion=<<$S/W version>> -Dpackaging=jar -Dfile=<<$Path to the jar file>>

Friday, November 30, 2007

Trac Installation

For Ubuntu 7.10.

$ apt-get install trac
$ sudo mkdir /var/trac
$ cd /var/trac
$ trac-admin test initenv
$ chown -R www-data ./test

$ apt-get install libapache2-mod-python
$ vi /etc/apache2/sites-available/trac
Alias /trac "/usr/share/trac/htdocs/"

<Location "/tracsvn">
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracUriRoot "/tracsvn"
PythonOption TracEnvParentDir /var/local/trac
AuthType Basic
AuthName "DoJa Repository"
AuthUserFile /etc/subversion/passwd
Require valid-user
$ a2ensite trac
$ /etc/init.d/apache2 reload

Subversion Installation

For Ubuntu 7.10
$ sudo apt-get install subversion libapache2-svn
$ sudo mkdir /var/svn
$ sudo svnadmin create /var/svn/$REPOS
$ sudo chown -R www-data:www-data /var/svn/$REPOS
$ sudo chmod -R g+ws /var/svn/$REPOS

Only allowing to access by SSL
$ sudo a2enmod ssl
$ sudo apt-get install ssl-cert

#In order to change the valid days up to 10years
#vi /usr/sbin/make-ssl-cert
openssl req -config $TMPFILE -new -days 365 -x509 -nodes -out $output -keyout $output > /dev/null 2>&1
$ sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
$ sudo chmod a+r /etc/apache2/ssl/apache.pem

$ cp /etc/apache2/sites-available/default /etc/apache2/sites-available/$SITENAME
$ sudo vim /etc/apache2/sites-available/$SITENAME
NameVirtualHost *:443

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all

Thursday, November 29, 2007

MySQL Encoding

You need to change params for the server and the client.
# Change MySQL server encode
# By calling the following SQL you can see the current encoding.
# show create table xxx;
# show variables like 'char%';

mysql$ alter table xxx character set utf8;
mysql$ alter table xxx change sub1 sub1 varchar(256) character set utf8;
mysql$ set names utf8;
mysql$ set character_set_database=utf8
mysql$ set character_set_server=utf8

#On the client to connet to DB set the following param in URL

Bind Reload

Bind reload command differs from the 8 or 9.
#/usr/sbin/ndc reload

#/usr/sbin/rndc reload

Friday, November 23, 2007

Eclipse Heap Memory

This is how you can change the memory for Eclipse to use.

#vim $ECLIPSE_HOME/eclipse.ini

Tomcat Heap Memory

Here is the how we can change the setting of the memory used for tomcat.

set CATALINA_OPTS="-Xms512m -Xmx512m"  (Windows)
export CATALINA_OPTS="-Xms512m -Xmx512m" (ksh/bash)
setenv CATALINA_OPTS "-Xms512m -Xmx512m" (tcsh/csh)

Java:Loading the file

The dev environment and the actual service server are different and often face the problem of path to the config file with FileNotFound Exception or so. Here is a solution.

URL propXML = this.getClass().getResource(RESFILE);
Configuration config = new XMLConfiguration(propXML);


ClassLoader loader = Thread.currentThread().getContextClassLoader();

Friday, November 16, 2007

Ubuntu: Change Timezone

The way to change the timezone.

root # ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
root # date -d

Monday, August 13, 2007

Formats decimal numbers by Java

DecimalFormat df = new DecimalFormat("0000");
#OUTPUT: 0077

DecimalFormat df = new DecimalFormat("####");

DecimalFormat df = new DecimalFormat("####%");
#OUTPUT: 77%

DecimalFormat df = new DecimalFormat("'AA'####%");

DecimalFormat df = new DecimalFormat("\u00A5###,###");
#OUTPUT: \7,777

Thursday, August 02, 2007

Struts2 by Maven for Eclipse

mvn archetype:create -DgroupId=tutorial \
-DartifactId=tutorial \
-DarchetypeGroupId=org.apache.struts \
-DarchetypeArtifactId=struts2-archetype-starter \
-DarchetypeVersion=2.0.1-SNAPSHOT \

cd tutorial
mvn -Dwtpversion=1.0 eclipse:eclipse

Monday, July 30, 2007

Tomcat & MySQL connection Error

Long absense after establishing the connection to MySQL from Hibernate, you might face the error below:
,406 ERROR JDBCExceptionReporter - Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTIOROR JDBCExceptionReporter - Communications link failure due to underlying exception
at com.mysql.jdbc.MysqlIO.readFully(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.Connection.execSQL(
at com.mysql.jdbc.PreparedStatement.executeInternal(
at com.mysql.jdbc.PreparedStatement.executeQuery(
at org.hibernate.jdbc.AbstractBatcher.getResultSet(
at org.hibernate.loader.Loader.getResultSet(
at org.hibernate.loader.Loader.doQuery(

Then you can add the following setting in configuration file of hibernate.

Wednesday, June 27, 2007

UnknownHostException @ Tomcat

#vim /etc/hosts

-- hostname

Protocol Analyzer in CUI

For CUI protocol analyzer,

#apt-get install tshark
#tshark -i eth0 -w `date "+%Y%m%d_capture.pcap"` -R "tcp.port==8080"

-w : output file
-R : filter

Friday, June 22, 2007

Maven with Eclipse A-Z

The simplest A-Z for Maven with Eclipse.
$mvn archetype:create -DgroupId=xx.xx.XX -DartifactId=AppName -Dversion=0.0.1
$mvn eclipse:add-maven-repo -Declipse.workspace=/home/user/workspace
#Move to the project root folder, then..
$mvn eclipse:eclipse -DdownloadSources=true

It's done. Then import the project from the Eclipse and enjoy ;-)

Wednesday, June 20, 2007

AccessControlException By Java

When you deploy the contents you might face the AccessControlException which is cased by java security manager. By Ubuntu packaged tomcat5.5, you can edit the policy file.

$sudo vim /etc/tomcat5.5/policy.d/99examples.policy

grant codeBase "file:${catalina.home}/webapps/gprs/-" {

The example above is the most loose security setting.

Hibernate cfg.xml file

hibernate.cfg.xml file not found issue is the one which troubles us often when we create the web app with hibernate. Here is the workaround code for this issue.

File file=
new File(getServletContext().getRealPath("/WEB-INF/classes/hibernate.cfg.xml"));
SessionFactory sessionFactory =
new Configuration().configure(file).buildSessionFactory();

Sunday, June 17, 2007

Ubuntu Java configuration

In case you need to change the version of java runtime environment which has been installed on you machine. It's simple as this,
$  sudo /usr/sbin/update-alternatives  --config   java

Wednesday, June 13, 2007

Ubuntu Default editor change

sudo update-alternatives --config editor

Ubuntu cron

Crontab on Ubuntu doesn't work with normal grammer. You need to add.

command > /dev/null 2>&1

Tuesday, June 12, 2007

Maven2 with Hibernate

Maven cannot solve the dependency regarding jta as it is released by Sun and based upon their binary license it cannot be deployed on the maven repository.

You will see something like this below.
1) javax.transaction:jta:jar:1.0.1B
Try downloading the file manually from:
Then, install it using the command:
mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta \
-Dversion=1.0.1B -Dpackaging=jar -Dfile=/path/to/file
Path to dependency:
1) RssUpdater:RssUpdater:package:0.0.1
3) javax.transaction:jta:jar:1.0.1B
1 required artifact is missing.
for artifact:
from the specified remote repositories: (, (,
central (

In order to avoid this, download jta and deploy it onto your local maven repos.

mvn install:install-file \
-Dfile=./ \
-DgroupId=javax.transaction \
-DartifactId=jta -Dversion=1.0.1B \

Thursday, June 07, 2007

Ubuntu webdav

The problem probably you face as followed.
[Sat May 19 13:20:21 2007] [notice]
Apache/2.2.3 (Ubuntu) DAV/2 PHP/5.2.1 configured
-- resuming normal operations
[Sat May 19 13:20:53 2007] [error] [client]
Could not DELETE /davhome/show.txt due to a failed precondition
(e.g. locks). [500, #0]
[Sat May 19 13:20:53 2007] [error] [client]
The locks could not be queried for verification against a possible
"If:" header. [500, #0]
[Sat May 19 13:20:53 2007] [error] [client]
Could not open the lock database. [500, #400]
[Sat May 19 13:20:53 2007] [error] [client]
(13)Permission denied: Could not open property database. [500, #1]

$ sudo touch /var/lock/apache2/DAVLock
$ sudo chown www-data /var/lock/apache2/DAVLock

Tuesday, June 05, 2007

NW setting of Ubuntu on VMPlayer

This is small note of how to set network setting of "vmx" for Ubuntu as it didn't work at the original one.
#ethernet0.virtualDev = "vmxnet" <- Comment this line as it doesn't recognize device.
ethernet0.virtualDev = "e1000"

#vim /etc/network/interface
auto eth0
iface eth0 inet dhcp

Thursday, May 17, 2007

Commons Digester Variable

The variable in xml data can be converted with Digester with the easy following codes.
Digester digester = DigesterLoader.createDigester(getURL(ruleFile));
Map vars = new HashMap();
MultiVariableExpander expander = new MultiVariableExpander();
expander.addSource("$", vars);
Substitutor substitutor = new VariableSubstitutor(expander);

Tuesday, May 15, 2007

Commons Lang toString()

Jakarta Commons Lang support the reflection for toString() which need to synchronize with the changes made for the object model.

public String toString(){
return ReflectionToStringBuilder.toString(this);

For the customization of the output,
public String toString(){
return ReflectionToStringBuilder.toString(this,ToStringStyle.MULTI_LINE_STYLE)

Sunday, May 13, 2007

Encoding to 3gp file for mobile phones

If h/s support AAC.
#ffmpeg -i infile.mpeg -vcodec mpeg4 -r 15 -b 128k -s qcif -acodec aac -ar 8000
-ac 1 -ab 13 -f 3gp -y output.3gp

If not
ffmpeg -i infile.mpeg -vcodec mpeg4 -r 15 -b 128k -s qcif -acodec amr_nb -ar 8000
-ac 1 -ab 13 -f 3gp -y output.3gp

For video editing on Linux, LiVES would be very nice.

Monday, March 19, 2007

Tomcat JkShmFile

Under the default config, you might get error when you boot up the tomcat saying,

jk_child_init::mod_jk.c (2317): Attachning shm:/etc/apache2/logs/jk-runtime-status errno=2

Write the following in /etc/apache2/mod-available/jk.load
JkShmFile /var/log/apache2/jk-runtime-status

Friday, January 05, 2007

Beautiful Font

Download M+font from

then follow..
% sudo apt-get install fontforge
% tar xvfz mplus-TESTFLIGHT-012.tar.gz
% cd mplus-TESTFLIGHT-012
% sudo cp /usr/share/fonts/truetype/ipa/ipag.ttf .
% sudo fontforge -script
% sudo mkdir /usr/share/fonts/truetype/mplus
% sudo mv M*IPAG.ttf /usr/share/fonts/truetype/mplus/.
% sudo fc-cache -f -v /usr/share/fonts/truetype/mplus