Make It Open

The Answer to Life, the Universe, and Everything

Wednesday, January 21, 2009

Struts2: <img src="${url}"/>

In case of specifying the url for the image in struts2, you can write as follows.

<s:iterator value="books" status="rowstatus">
<s:url id="url" value="%{bookImagePath[#rowstatus.index]}"/>
<img src="${url}" alt="Book image" align="top"/>

Thursday, January 08, 2009

ERROR JDBCExceptionReporter - Duplicate entry

By using mysql, I faced the followin error and here is the solution
2009-01-08 22:55:18,454  WARN JDBCExceptionReporter - SQL Error: 1062, SQLState: 23000
2009-01-08 22:55:18,454 ERROR JDBCExceptionReporter - Duplicate entry '268731' for key 1
2009-01-08 22:55:18,454 ERROR AbstractFlushingEventListener - Could not synchronize database state with sessi
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

Close the session after transaction.commit().

Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost

I faced the following error and here is the solution.
MESSAGE: Can not read response from server. Expected to read 4 bytes, read 2
bytes before connection was unexpectedly lost.

STACKTRACE: Can not read response from server. Expected to read 4
bytes, read 2 bytes before connection was unexpectedly lost.

Comment the wait_timeout such as below.

Tuesday, January 06, 2009

SocketException: Too many open files

If you see the following error, Too many open files

Try to change the max open file value for the user

#check current value by calling
ulimit -a
#Set new max open file
ulimit -n 102400

as well as the OS

#Check current value
cat /proc/sys/fs/file-max
#Set the new max open file by adding the following
vi /etc/sysctl.conf
fs.file-max = 49500

Tuesday, December 23, 2008

SQL Error: 0, SQLState: 08S01

If you see the such a error by using hibernate3, you need the following to avoid it.
JDBCExceptionReporter SQL Error: 0, SQLState: 08S01

In hibernate.cfg.xml, write

<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">50</property>

Then create "" in your root classpath folder and write

Wednesday, December 10, 2008

Illegal mix of collations in MySQL

In case for having such a error in mysql using Hibernate or so.

java.sql.SQLException: General error message
from server: "Illegal mix of collations
(utf8_general_ci,COERCIBLE) and
(latin1_swedish_ci,IMPLICIT) for operation '='"

Add the following in my.cnf
default-character-set = utf8

init-connect=SET NAMES utf8

Monday, November 17, 2008

Apache2.2 : AuthUserFile Error

<Location /svn>
DAV svn
SVNParentPath "/var/svn"
AuthzSVNaccessFile /var/svn/.htpasswd
AuthType Basic
AUthName "Dev Project"
AuthUserFile /var/svn/.htpasswd

I set the basic authentication such as above which ended up the below error.
# /etc/init.d/apache2 reload
Syntax error on line 64 of /etc/apache2/mods-enabled/dav_svn.conf:
Invalid command 'AuthUserFile', perhaps misspelled or defined by a module not included in the server configuration

Since below,
$ for i in /usr/lib/apache2/modules/*; do strings $i | grep -q -i AuthUser && echo $i; done
$ ls /etc/apache2/mods-available/authn_file.load

You need to do as follow,
$ sudo /usr/sbin/a2enmod authn_file
Module authn_file installed; run /etc/init.d/apache2 force-reload to enable.
$ /usr/sbin/apache2ctl configtest
Syntax OK

Friday, November 14, 2008

JBoss Setting

After the installation of JBoss, here is the know-how of its setting.

1) Heap size
$ sudo vim $JBOSS/bin/run.conf

JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
JAVA_OPTS="-Xms512m -Xmx768m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

2) Port check
vim $JBOSS/server/default/deploy/jboss-web.deployer/server.xml

3) Transaction time out
vim $JBOSS/server/default/conf/jboss-service.xml


4) Thread number
vim server/default/deploy/jboss-web.deployer/server.xml


5) Log Output level by log4j
vim /opt/jboss-4.2.3.GA/server/default/conf/jboss-log4j.xml 
<priority value="WARN" />
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>

Thursday, November 13, 2008

Struts2 and Hibernate v3 Min. Lib.

Those are the minimum required libraries for Struts2 and Hibernate v3.




Monday, August 18, 2008

Log4J Log rotate

It's better to log rotate by Java side than using Linux/Unix logrotate.
This is the example for log4J v1.2x (The v1.3 development is stopped by the way.) series , "log4j.xml" file.

By using DailyRollingFileAppender, you can log rotate as the date base.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="">
<!--Definition of the File Appender -->
<appender name="file" class="org.apache.log4j.DailyRollingFileAppender">
<!-- Date pattern policy -->
<param name="DatePattern" value=".yyyy-ww" />

<param name="File" value="logs/hibernate.log"/>
<!-- Log append -->
<param name="Append" value="true" />

<!-- Log layout -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c{1} - %m%n" />

<!-- Default log level -->
<param name="threshold" value="info"/>


<!--Console log appender -->
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<!-- Default log level -->
<param name="threshold" value="info"/>
<!-- log layout -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c{1} - %m%n"/>

<appender-ref ref="stdout"/>
<appender-ref ref="file"/>

Saturday, June 07, 2008

File code converting

After moving from Windows dev. environment to Linux, source file needs to be converted to UTF8 from Shift_JIS. It's done easily.
 find ./* -type f -name '*.java' -exec nkf -Luw --overwrite {} \;

Tuesday, May 27, 2008

Flv file convert

Flv file convert to music format

.flv to mp3
$ ffmpeg -i xxx.flv -vn -acodec aac -ab 128k -ac 2 -ar 44100 -y test.mp3

.flv to aac
$ ffmpeg -i xxx.flv -vn -acodec mp3 -ab 128k -ac 2 -ar 44100 -y test.mp3

.flv to mp4
$ ffmpeg -bitexact -y -i OLD_TOWN.flv -vcodec mpeg4 -s 320x240 -r 25 -b 480k -acodec aac -ac 2 
-ar 22050 -ab 69k out.mp4

To cut mp3 then
$ sudo apt-get install poc-streamer
#mp3cut [ -o outputfile ] [ -T title ] [ -A artist ] [ -N album-name ]
[ -t [hh:]mm:ss[+ms]-[hh:]mm:ss[+ms] ] mp3file [[ -t … ] mp3file1 …]

$ mp3cut -o cut.mp3 -t 00:08-00:49 test.mp3

Wednesday, May 21, 2008

Awstats for Ubuntu

awstats is log analyzer I use it for tomcat log analysis.

<Host name="localhost" appBase="webapps" >
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="ich_access_log."
suffix=".txt" pattern="combined" resolveHost="false" / >
</Host >

Setting for awstats

cp -r /usr/share/awstats/icon /var/www/awstats-icon
/usr/lib/cgi-bin/ -config=hostname -update

Then access to :http://hostname/cgi-bin/

Edit cron

crontab -e
0 1 * * * /usr/lib/cgi-bin/ -config=hostname -update

Wednesday, May 14, 2008

Firefox3 Plugins

I've been using Hardy 8.04 which implements Firefox3.0b5.
Still many of FF plug-ins are not supported for FF3. If you want to use it by any means.

1) about:config
2) Choose New>Boolean. Then "checkCompatibility" to "false".
3) Choose New>Boolean. "checkUpdateSecurity" to "false".
4) Restart Firefox and done ;-)

Thursday, March 06, 2008

Change the folder name in English

Change the default folder such as Music/Document etc. name in English.

LANG=C xdg-user-dirs-gtk-update

Monday, February 25, 2008



# Created by newuser for 4.3.4

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:/opt/apache-maven-2.0.8/bin

alias eclipse='/opt/eclipse/eclipse'
alias update='sudo apt-get update'
alias upgrade='sudo apt-get upgrade'
alias du="du -h"
alias df="df -h"
alias ps="ps -aux"

# For auto compinit
autoload -U compinit

# For prompt
PROMPT="%/%% "
PROMPT2="%_%% "
SPROMPT="%r is correct? [n,y,a,e]: "

# For title bar
case "${TERM}" in
precmd() {
echo -ne "\033]0;${USER}@${HOST%%.*}:${PWD}\007"

# For history function
setopt hist_ignore_dups # ignore duplication command history list
setopt share_history # share command history data

# For History search shortcut
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^P" history-beginning-search-backward-end
bindkey "^N" history-beginning-search-forward-end

# Editor vi mode
bindkey -v

# For remembering the previous folder
setopt auto_pushd

# No beep
setopt nolistbeep

# For auto-prediction function
autoload predict-on

Saturday, February 09, 2008

Ubuntu Gutsy Step1

I just bought Dell Inspiron 1720 for my private note PC.
I certainly decided to delete Vista and then install Ubuntu for the box.
This is step by step set up for my reminder.
I skip writing the way to add apt line or so as it is too easy procedure to forget.

*Sound - you need to install the following package to enable the sound

$ sudo apt-get install linux-backports-modules-generic

1) I suggest to visit here for your little preparation

2) Font installation

% 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

#Mikacha for the same step

3) Then go to forum to see what you want to do.

4) Adobe related s/w
Flash capability is important. Visit adobe page to download the flash player.

$ tar zvxf install_flash_player_9_linux.tar.gz
$ cd install_flash_player_9_linux/
$ sudo ./flashplayer-installer

Copyright(C) 2002-2006 Adobe Macromedia Software LLC. All rights reserved.
Adobe Flash Player 9 for Linux
Adobe Flash Player 9 will be installed on this machine.
You are running the Adobe Flash Player installer as the "root" user.
Adobe Flash Player 9 will be installed system-wide.
Support is available at
To install Adobe Flash Player 9 now, press ENTER.
To cancel the installation at any time, press Control-C.
NOTE: Please exit any browsers you may have running.
Press ENTER to continue...
Please enter the installation path of the Mozilla, Netscape,
or Opera browser (i.e., /usr/lib/mozilla): /usr/lib/firefox

----------- Install Action Summary -----------
Adobe Flash Player 9 will be installed in the following directory:
Browser installation directory = /usr/lib/firefox
Proceed with the installation? (y/n/q): y
Installation complete.
Perform another installation? (y/n): n
Please log out of this session and log in for the changes to take effect.
The Adobe Flash Player installation is complete.

#Then PDF
$sudo aptitude install acroread acroread-plugins acroread-escript
$sudo aptitude install mozilla-acroread

--set at the first launch :: Edit -> Prefences -> Interne
Browser Executable: /usr/bin/firefox
libgtkembedmoz Folder: /usr/lib/firefox/

5) java capability

$ sudo apt-get install sun-java6-jre sun-java6-plugin
$ sudo update-java-alternatives -s java-6-sun
$ sudo vim /etc/jvm
#Add the following line in the top of the file

Friday, January 11, 2008

MySQL5 character set

All you need to edit my.cnf in order not to write the command like "set name xxx" everytime you restart the service.

default-character-set = utf8

default-character-set = utf8
character-set-server = utf8
collation-server = utf8_general_ci
init-connect = SET NAMES utf8

default-character-set = utf8

default-character-set = utf8

In order to check the charset

mysql> shwo variables like 'char%';
| Variable_name | Value |
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |

#Then set charset
mysql>set character_set_database=utf8
mysql> show variables like 'char%';
| Variable_name | Value |
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |

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.