Thursday, November 08, 2007

Myfaces 1.1.5 with RichFaces 3.1.1
There is a compatibility problem between these libraries. The richfaces interference the component creation cycle and cached the creation process. The component will be re-created even the page is in first load, which fail the t:saveState.

Monday, October 15, 2007

Installation location of JBoss 4.0.4
The installation location of the JBoss 4.0.4 must not contains a whitespace, else it'll throw MalFormedURLException during the EJB lookup

Sunday, October 14, 2007

Remote X Window using Cygwin
  1. Download Cygwin and install it in any Win32 machine
  2. In the Linux server, assume Gnome is the display manager, type "gdmsetup" and enable the XDMCP.
  3. Open the bash shell in Cygwin, type "XWin -query "

Tuesday, June 26, 2007

Handling Chinese Characters in JSF/JSP
The best way to handling chinese encoding problem is to install a JSP filter.

Friday, February 23, 2007

JBoss AOP Part 2

The previous post was about using JBoss AOP with load time weaving. This feature
is great because there is no need for post compilation, the transformer will
weave the AOP code to the normal Java bytecode automatically without any
intervention. However, it failed in my project becoz there are many classes and
the transformer is always complain about out of memory. The JBoss forum said
this bug won't be fixed until the next two release. Since I'm die hard to try
the Jboss AOP. I took the precompile approach. The steps are listed as
followings

  1. Add the following in ur ant build script for AOP precompilation in netbeans

    <target name="-pre-dist">
    <path id="javassist.classpath">
    <pathelement path="/usr/local/share/download/jboss-aop_1.5.0.GA/lib-50/javassist.jar"/>
    </path>
    <path id="trove.classpath">
    <pathelement path="/usr/local/share/download/jboss-aop_1.5.0.GA/lib-50/trove.jar"/>
    </path>
    <path id="concurrent.classpath">
    <pathelement path="/usr/local/share/download/jboss-aop_1.5.0.GA/lib-50/concurrent.jar"/>
    </path>
    <path id="jboss.common.classpath">
    <pathelement path="/usr/local/share/download/jboss-aop_1.5.0.GA/lib-50/jboss-common.jar"/> </path>
    <path id="lib.classpath">
    <path refid="javassist.classpath"/>
    <path refid="trove.classpath"/>
    <path refid="jboss.aop.classpath"/>
    <path refid="jboss.common.classpath"/>
    <path refid="concurrent.classpath"/>
    </path>
    <path id="jboss.aop.classpath">
    <pathelement
    path="/usr/local/share/download/jboss-aop_1.5.0.GA/lib-50/jboss-aop-jdk50.jar"/>
    </path>
    <path id="local.lib">
    <fileset file="${build.web.dir.real}/WEB-INF/lib/*.jar">
    </fileset>
    </path>
    <path id="classpath">
    <path refid="lib.classpath"/>
    <path refid="jboss.aop.classpath"/>
    <path refid="local.lib"/>
    </path>
    <property name="aop.config.filepath"
    value="${src.dir}/MFT-SIDS-war-aop.xml"></property>
    <taskdef name="aopc15" classname="org.jboss.aop.ant.AopC"
    classpathref="jboss.aop.classpath"/>
    <aopc15 compiler classpathref="classpath" verbose="true"
    optimized="false">
    <classpath path="${build.classes.dir}"/>
    <src path="${build.classes.dir}"/>
    <include name="**/*.class"/>
    <aoppath path="${aop.config.filepath}"></aoppath>
    <aopclasspath path="${build.classes.dir}"/>
    </aopc15>
    <copy file="${aop.config.filepath}"
    todir="/usr/local/share/app/jboss-4.0.4.GA/server/default/deploy">
    </copy>
    </target>

  2. Assumed the development platform is JBoss 4.0.4 GA(Bundled with Netbeans). The client application needs to include the extra client file "jboss-aspect-jdk50-client.jar". In addition, it requires the file "jboss-aop-jdk50.jar" to compile the project. But DO NOT include it to the deployment package

Tuesday, February 20, 2007

Startup parameter for JBoss clustering
For some reasons, the clustering doesn't work until start the run.sh with -b "{IPAddress} parameter. This cause a big problem since the Netbeans Jboss plugin doesn't allow me to insert any custom parameters. Finally I have to modify the "{Jboss}/server/default/deploy/cluster-service.xml" file and change the "NodeAddress" to a real IP. Then I can start the clustered JBoss in Netbeans
JSF onValueChangeListener Bug
Myfaces seems to have a problem when there are two SelectOneMenu and each of them has a value change listener. When both of them have the "rendered" attribute is set, the second SelectOneMenu seems will never have the valueChangeListener fired. I fixed this problem by using the JSTL's c:if
JSF & JSTL
I experienced something strange about JSF & JSTL. The test attribute of the JSTL's c:if seems always evaluated to false. Finally I have figured out that it is related to the web.xml file, I need to use the servlet 2.4's DTD and everything works fine. That is weird

Friday, February 16, 2007

Configure JBoss AOP 1.5.3 FOR JBoss 4.0.4 GA
  1. Download the JBoss AOP package
  2. Copy all the files in the directory "{JBoss-AOP-1.5.3}/lib-50" into "{Jboss}/server/default/lib"
  3. Remove the old "jboss-aop-deplopyer" from the "{Jboss}/server/default/deploy" if any
  4. Copy the whole directory from "{JBoss-AOP-1.5.3}/jboss-40-install/jboss-aop-jdk50.deployer" to the directory "{Jboss}/server/default/deploy"
  5. Remove the files "javassist.jar" and "common-softwarevaluehashmap.jar" from the "{Jboss}/server/default/deploy/jboss-aop-jdk50.deployer" directory.
  6. Edit the "{Jboss}/server/default/deploy/jboss-aop-jdk50.deployer/META-INF/jboss-service.xml" file, set the "EnableLoadtimeWeaving" to true, in the "Exclude" attribute, add ",org.apache.,org.quartz.,java."

    The following shows the file content
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- $Id: jboss-service.xml 44143 2006-04-24 18:19:21Z kkhan $ -->
    <!--
    =====================================================================
    -->
    <!-- JBoss Server
    Configuration
    -->
    <!--
    =====================================================================
    -->
    <server>
    <!-- The code for the service is different for the
    different run scenarios
    *** JBoss 4.0
    * JDK 1.4 -
    org.jboss.aop.deployment.AspectManagerService
    * JDK 5 (not
    using -javaagent switch) - org.jboss.aop.deployment.AspectManagerService
    * JDK 5 (using
    -javaagent switch) - org.jboss.aop.deployment.AspectManagerServiceJDK5
    * BEA JRockit
    1.4.2 - org.jboss.aop.deployment.AspectManagerService
    *** JBoss 3.2
    * JDK 1.4 -
    org.jboss.aop.deployment.AspectManagerService32
    * JDK 5 (not
    using -javaagent switch) -
    org.jboss.aop.deployment.AspectManagerService32
    * JDK 5 (using
    -javaagent switch) - org.jboss.aop.deployment.AspectManagerService32JDK5
    * BEA JRockit
    1.4.2 - org.jboss.aop.deployment.AspectManagerService32
    -->
    <mbean
    code="org.jboss.aop.deployment.AspectManagerServiceJDK5"
    name="jboss.aop:service=AspectManager">
    <attribute
    name="EnableLoadtimeWeaving">true</attribute>
    <!-- only relevant when
    EnableLoadtimeWeaving is true.
    When
    transformer is on, every loaded class gets
    transformed. If AOP can't find the class, then it throws an
    exception. Sometimes, classes may not have
    all the
    classes they reference. So, the Suppressing
    is
    needed. (i.e. Jboss cache in the default configuration -->
    <attribute
    name="SuppressTransformationErrors">true</attribute>
    <attribute
    name="Prune">true</attribute>
    <attribute
    name="Include">org.jboss.test, org.jboss.injbossaop</attribute>
    <attribute
    name="Exclude">org.jboss.,org.apache.,org.quartz.,java.</attribute>
    <!-- This avoids instrumentation of
    hibernate cglib enhanced proxies-->
    <attribute
    name="Ignore">*$$EnhancerByCGLIB$$*</attribute>
    <attribute
    name="Optimized">true</attribute><attribute
    name="Verbose">false</attribute>
    </mbean>
    <mbean code="org.jboss.aop.deployment.AspectDeployer"
    name="jboss.aop:service=AspectDeployer">
    </mbean>
    </server>

  7. Edit the file "{Jboss}/server/bin/run.sh" , change the line JAVA_OPTS to the following
    JAVA_OPTS="$JAVA_OPTS -Dprogram.name=$PROGNAME -javaagent:/usr/local/share/app/jboss-4.0.4.GA-test/server/default/lib/pluggable-instrumentor.jar"