Setup Jboss Ent. With Liferay Portal

30 06 2008

My Environment

Jboss Boss AS Ent. 4.3.0.G.A

LifeRay Portal 4.4.2

MySql 5.0.45 community

(Linux and Windows almost use the same setting steps)

1. run the Jboss AS installer to install it.

Windows : double click

Linux : terminal>java -jar enterprise-installer-4.3.0.GA-1.ep1.8.jar

2. install MySql from its installer.

3. download 3 files of liferay :

liferay-portal-4.4.2-with-dependencies.war

liferay-portal-dependencies-4.4.2.zip

liferay-portal-sql-4.4.2.zip

4. create an utf-8 database in your mysql, I use lportal as database name here.

mysql>create database lportal character set utf8;

5. unpack liferay-portal-sql-4.4.2.zip, import the database dump under [unpack]/create-minimal/create-minimal-mysql.sql

mysql -uroot lportal < [path from above]/create-minial-mysql.sql –default-character-set=utf8

6. open [JBOSS_HOME]/jboss-as/server/default/deploy/jboss-web.deployer/conf/web.xml

Replace :

<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

With :

<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servletclass>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>input</param-name>
<param-value>4096</param-value>
</init-param>
<init-param>
<param-name>output</param-name>
<param-value>4096</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

7. create [JBOSS_HOME]/jboss-as/server/default/deploy/liferay-ds.xml

<?xml version="1.0"?>
<datasources>
	<local-tx-datasource>
		<jndi-name>jdbc/LiferayPool</jndi-name>
		<connection-url>jdbc:mysql://hostname:3306/lportal</connection-url>
		<driver-class>com.mysql.jdbc.Driver</driver-class>
		<user-name></user-name>
		<password></password>
		<min-pool-size>5</min-pool-size>
	</local-tx-datasource>
</datasources>

8. Download mysql-connector-java-5.1.5-bin.jar, copy to [JBOSS_HOME]/jboss-as/server/default/lib/

9. Unpack liferay-portal-dependencies-4.4.2.zip to [JBOSS_HOME]/jboss-as/server/default/lib/

resulting structure will be like this :

[JBOSS_HOME]/jboss-as/server/default/lib/liferay-portal-dependencies-4.4.2/portlet.jar

/portal-kernel.jar

/portal-service.jar

10 .Setup mail properties, open [JBOSS_HOME]/jboss-as/server/default/deploy/mail-service.xml

modify : User, Password, pop3.host, smtp.host, mail.from

11. Open [JBOSS_HOME]/jboss-as/server/default/conf/login-config.xml, comment out the entire <application-policy name=”other”>

12. unpack liferay-portal-4.4.2-with-dependencies.war, rename the unpacked folder to liferay-portal.war

Move dom4j.jar, jaxen.jar from liferay-portal.war/WEB-INF/lib to [JBOSS_HOME]/jboss-as/lib

Move commons-collections.jar from liferay-portal.war/WEB-INF/lib to [JBOSS_HOME]/jboss-as/server/default/lib (overwrite it if it is already there)

remove hibernate3.jar, jboss-hibernate.jar from [JBOSS_HOME]/jboss-as/server/default/lib

Move liferay-portal.war to [JBOSS_HOME]/jboss-as/server/default/deploy/

13. open [JBOSS_HOME]/jboss-as/server/default/deploy/jbossjca-service.xml

change <attribute name=”Debug”>true</attribute>

to <attribute name=”Debug”>false</attribute>

14. open [JBOSS_HOME]/jboss-as/server/default/deploy/jboss-messaging.sar/destinations-service.xml

clear all text between <server></server>

15. open [JBOSS_HOME]/jboss-as/bin/run.conf

modify the JAVA_OPTS setting to this one

      JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxNewSize=256m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

16. But in my experience, JBoss Ent. may not pick up this setting in windows, so

Windows : open [JBOSS_HOME]/jboss-as/bin/run.bat

find : rem JVM memory allocation pool parameters. Modify as appropriate.

change the line follow this one to

set JAVA_OPTS=%JAVA_OPTS% -Xms256m -Xmx512m -XX:MaxNewSize=256m -XX:MaxPermSize=256m

17. start Jboss AS, beware that there are more then one AS : All, default, minimal, production.

The one we setup is default, you can start by

Windows : [JBOSS_HOME]/jboss-as/bin/run.bat -c default

Linux : [JBOSS_HOME]/jboss-as/bin/run.sh -c default

18. open http://localhost:8080, you should see liferay running

19. change the Jboss AS to allow remote connection and bind to port 80

open [JBOSS_HOME]/jboss-as/server/default/deploy/jboss-web.deployer/server.xml

change :

    <Connector port="8080" address="${jboss.bind.address}"
         maxThreads="250" maxHttpHeaderSize="8192"
         emptySessionPath="true" protocol="HTTP/1.1"
         enableLookups="false" redirectPort="8443" acceptCount="100"
         connectionTimeout="20000" disableUploadTimeout="true" />

to :

    <Connector port="80" address="0.0.0.0"
         maxThreads="250" maxHttpHeaderSize="8192"
         emptySessionPath="true" protocol="HTTP/1.1"
         enableLookups="false" redirectPort="8443" acceptCount="100"
         connectionTimeout="20000" disableUploadTimeout="true" />

Then reboot JBoss AS.





MySql 5 basic handling of utf-8 database

30 06 2008

1. Setup default mysql character set
modify mysql.cnf
[client]
default_character_set=utf8
[mysqld]
default-character-set=utf8
character-set-server = utf8
collation-server = utf8_general_ci
[mysql]
default_character_set=utf8

You will need to setup apache too if your website need utf-8
modify \apache\conf\extra\httpd-languages.conf
find :
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw
add :
AddLanguage UTF-8 .utf8
find :
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
change :
LanguagePriority UTF-8 en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
add :
DefaultLanguage UTF-8
AddDefaultCharSet UTF-8

2. Check database character set
mysql>SHOW VARIABLES LIKE ‘character_set%’;
mysql>SHOW VARIABLES LIKE ‘collation%’;
Change database character set
mysql>SET NAMES utf8;
mysql>SET CHARACTER SET utf8;
mysql>SET GLOBAL/SESSION character_set_XXX=utf8

3. Create utf-8 database
mysql>create database db_name character set utf8;

4. Restore utf-8 dump
mysql -uroot dbname < dump.sql –default-character-set=utf8

Remark: please note that mysql start supporting utf-8 from 5.0





General terms and concept about version control

24 06 2008

I use SubVersion for version control.

commonly there are three directory :

/trunk
/branches
/tags

trunk is use for mainline development, where developer commit source to it everyday.

it is where the latest source located. for keeping daily changes.

branch is a line of development that exists independently, but share a common history.

just like Joomla and Mambo. for keeping releases. e.g. version 1.0

tag is a snapshot of the whole project, just like a release. nobody should commit anything to it.

e.g. version 1.0.0

bugs and features are handled in trunk and then port to branch, you may take another snapshot. e.g. version 1.0.1.

if a core design or architecture change, then move to another branch. e.g. version 2.0.

this is just a concept, you should find your own which makes you comfortable.





Using SVN (Tortoise) on local binary files

19 06 2008

Well, I used to use svn on software development.

But I never setup the svn server, that’s not my resposibility.

When I play some games recently, I start to think,

maybe I can do a version control on autosave game.

Then I use tortoise, a svn client and Diablo 2 to test it.

Tortoise is claimed to be a svn client, but the thing is, it works

just like a server on local files. hmm, makes me wonder what ‘client’ means.

anyway, here is the flow of how to use it on game save.

1. create a folder for your repository.

and then right-click on it, select ‘create repository …’

then just use default setting.

2. go to the game save folder, right-click, select ‘import…’

search the repository folder in your file system, import into it.

3. delete you files in the game save folder.

then right-click on the folder, select ‘check out…’

3. check out those files, then you are ready, those files are now monitored by svn.

if they are modified, a red cross will be shown, you can then commit new version to the repository.

if you want to revert to previous game save, just delete all files, right-click, choose ‘revert…’

Have fun with version control.





JasperReport/iReport useful basic technique.

13 06 2008

When I do reporting. There are some basic things that one commonly will do.

No matter I am using Crystal Report or Jasper Report of other reporting tools.

1. some statistic result, usually I do this with parameter passing.

2. some mapping to make the data more human readable.

3. sub-report dataset. a little complex, not discuss in this post.

The first one is the easiest in Jasper Report. Just pass a parameter map when you fill the report with data.
HashMap paramMap = new HashMap();
paramMap.put(”NUMBER_ADMISSION”,attendanceList.size());
reportInstance = JasperCompileManager.compileReport(”c:/jasperXml/admissionReport0613.jrxml”);
jasperPrint = JasperFillManager.fillReport(reportInstance,paramMap,new JRBeanCollectionDataSource(attendanceList));

This pass the number of records as a parameter. Many report have this kind of field.

Then you can get is in the report by $P{keyOfMap}.

2. the second one is a little bit tricky. Due to iReport not so clear importing and classpath handling.

I am still not very sure which step(s) make this right. but I will tell you all that I’ve done to make it work.

i. you need to have a class with a static method to do the transformation for you. for example

MyFormatter.toStatusString(int statusInt);

ii. compile this .java into .class. and then add the directory containing .java and .class into iReport classpath.

do this by “Option->Classpath->add folder”.

for example adding “project\build\classes” and “project\src\package\”

iii. also add the package containing that class by “Edit->Import Report Directives->New Import”

example “my.package” where MyFormatter is in my.package.MyFormatter

iv. define an expression “MyFormatter.toStatusString($F{state})”

v. compile and save the report. If you Execute (with active connection), you may get a ClassDefNotFoundException.

vi. add “import my.package.MyFormatter” into the class where you generate the JasperPrint object.

After these steps, I finally can generate a report with ClassDefNotFoundException.

God Bless.





Ubuntu 用kopete上msn+scim打中文

30 05 2008

為甚麼用kopete,因為好像只有它跟aMSN有支援視訊
好像因為kopete是KDE的東西,ubuntu我用的應該是GNOME
所以在kopete裡面啟動不了scim中文輸入法

解決方法:
安裝scim-qtimm
在terminal輸入
sudo apt-get install scim-qtimm
再加一條指令,我想是在做設定的吧
im-switch -s scim_xim
他可能會說
update-alternatives: Cannot find alternative ‘/etc/X11/xinit/xinput.d/scim_xim’
但不用理他,現在Restart X window就可以了(ctrl+alt+backspace)





Scroll bar using CSS

28 05 2008

If you have content that is too long or too wide and
you want to add scroll bar to it, here is what to do.

for example:

<div id=”wrapper”>
<div id=”content”>some content</div>
</div>

If your content width/height is larger than its wrapper,

add overflow:auto to “wrapper” CSS style.





Useful HTML special character

28 05 2008
Character Representation
Non-Breaking Space &nbsp;
&quot;
< &lt;
> &gt;
& &amp;
© &copy;
® &reg;
¢ &cent;
° &deg;
² &sup2;
» &raquo;
« &laquo;
¼ &frac14;
½ &frac12;
¾ &frac34;
± &plusmn;
ü &uuml;
Ø &Oslash;
¡ &iexcl;
ñ &ntilde;




1pixel border <table> using CSS

28 05 2008

If you trying to do this by setting border of <table>, <tr>, <td>,
you won’t get what you want.

Let’s cut the crap, just use this style.
table, td{
border-color: #000000;
border-style: solid;
}
table{
border-width: 0 0 1px 1px;
border-spacing: 0;
border-collapse: collapse;
}
td{
margin: 0;
border-width: 1px 1px 0 0;
}





在Ubuntu安裝中文輸入法和使用中文介面

26 05 2008

這是我第一次在自己的Linux上用中文寫BLOG
我本來是Windows愛好者,所以設定Linux大概都想設定成跟Windows一樣

首先把Ubuntu轉成中文
System->management->language support
把中文打勾,然後Default Language設定為Chinese(Taiwan)
再來登出再登入,應該就看到中文介面了

再來安裝輸入法
你把Ubuntu設定成中文介面時,他應該就幫你裝好了SCIM
SCIM就是用來管理輸入法的東西
我們再來要設定他
系統->偏好設定->SCIM輸入法設定
選”介面->全域設定”,鍵盤排列選[英文]
作用鍵加入”ctrl+space”,就是用來開關中文輸入的快捷鍵
下一種輸入法加入”ctrl+L_shift”,就像Windows那樣轉輸入法
再來選”輸入法引擎->全域設定”,只選你要用的輸入法
再來登出再登入,就設定完成了 ^^

安裝Firefly字型
在terminal輸入以下指令
wget ftp://ftp.opendesktop.org.tw/odp/ODOFonts/OpenFonts/opendesktop-fonts-1.4.2.tar.gz
tar xvzf opendesktop-fonts-1.4.2.tar.gz
cd opendesktop-fonts-1.4.2
sudo cp odosung.ttc odokai-ExtB.ttf odokai.ttf odosung-ExtB.ttf /usr/local/share/fonts
sudo fc-cache -v

重新啟動 X-Window (ctrl+alt+backspace)
您可以透過 Gnome 面板上的[系統]->[偏好設定]->[字型],將字型更改為 AR PL New Sung(新宋) ,中文顯示會美觀許多。