Total Pageviews

2009/04/07

PMD



PMD scans Java source code and looks for potential problems like:
  • Possible bugs - empty try/catch/finally/switch statements
  • Dead code - unused local variables, parameters and private methods
  • Suboptimal code - wasteful String/StringBuffer usage
  • Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
  • Duplicate code - copied/pasted code means copied/pasted bugs
It can be plug-in to Eclipse, NetBeans, etc.

http://pmd.sourceforge.net/

2009/04/06

Utilize Jericho HTML Parser to Resolve NCR Problem

Agenda
  • What is NCR (Numeric Character Reference) ?
  • Scenario Description
  • Problem (XML with NCR)
  • Resolution Process
  • Result (NCR had been decoded)

http://www.slideshare.net/junyuo/utilize-jericho-html-parser-to-resolve-ncr-problem


2009/02/20

Problems running dot: exit code=-1, command='dot'

As I used Doxygen to generate source code docuemt, I failed to generate graphs and got this kind of error message: 
Problems running dot: exit code=-1, command='dot', arguments='"classcom_1_1htc_1_1hr_1_1tree_1_1_department_table_bean_50f82c9386b01669779a1524b380b355_cgraph.dot" -Tpng -o "classcom_1_1htc_1_1hr_1_1tree_1_1_department_table_bean_50f82c9386b01669779a1524b380b355_cgraph.png"'

I spent lots of time to resolve this odd issue, and found out its result from the wrong GraphViz version. I cannot use the latest version. As I tried graphviz-2.12.exe this version, all problems were gone. You can go to here to download this verion: http://www.graphviz.org/pub/graphviz/stable/windows/

Here is class hierarchy:


Here is call graph:

2009/02/18

Applied Apache Trinidad to show organization chart

Technology: Apache Trinidad, JPA

Web Container: Glassfish

Demo
1. enter personnel request application form page


2. launch popup window to show the organization chart


3. return the selected department back to original page


sequence diagram



trinidad page -- caller page


trinidad page -- popup window



PersonnelRequestController



DepartmentTableBean




you can also check the developer guide for futher information: http://myfaces.apache.org/trinidad/devguide/tree.html

2009/02/17

java.sql.SQLException: OALL8 is in an inconsistent state

Technology: Apache Trinidad, JPA

Web Container: glassfish

Database:
Oracle 10g


Scenario:
As I execute some functions, then it will get this error message

[#|2009-02-03T11:22:52.620+0800|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=15;_ThreadName=httpSSLWorkerThread-8080-1;|[TopLink Warning]: 2009.02.03 11:22:52.620--UnitOfWork(2726974)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: OALL8 is in an inconsistent state
Error Code: 17447
Call: SELECT ID, JOB_LOC_ENG_DESC, JOB_LOC_INFORM_ENG_DESC, DOMAIN, IS_JOB_LOC, CREATETIMESTAMP, IS_INTERVIEW_LOC, JOB_LOC_NATIVE_DESC, IS_ONBOARD_LOC, JOB_LOC_INFORM_NATIVE_DESC, JOB_LOCATION_CODE, MODIFYTIMESTAMP, MODIFIER, CREATOR FROM RSDB.JOB_LOCATION WHERE (ID = ?)
bind => [22612]
Query: ReadObjectQuery(com.htc.hr.entity.JobLocation)
|#]


Root Cause: I put collection object into hashCode function, it's the root cause to cause this error. Just remove it.

Set up a simple way to backup testing server database



1. write an ant build file to generate dump file and copy to remote machine (on a daily basis)

















2. create a batch file to execute my build script

3. add this batch file to scheduler service


4. result
[local machine]


[remote machine]

2009/01/14

NamedQuery of name: jobDutyJobTitle.findByJobDuty not found.

As I used JPA as my persistence tier implementation. I declared a named query in my entity class:










And I called this name query in my DAO class:












But as I ran my web application, it got this kind of error message (no matter the name of query or the sql statement is corrent):

java.lang.IllegalArgumentException: NamedQuery of name: jobDutyJobTitle.findByJobDuty not found. 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getDatabaseQuery(EJBQueryImpl.java:422) 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.setAsSQLReadQuery(EJBQueryImpl.java:136) 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:464) 
    at com.htc.hr.dao.JobDutyJobTitleDAO.findByJobDuty(JobDutyJobTitleDAO.java:41) 
    at com.htc.hr.controller.JobDutyController.showJobDutyJobTitle(JobDutyController.java:47)

The root cause is: I forgot to add this enity class declaration into persistence.xml

2009/01/06

An Introduction To JBoss RichFaces | Eclipse Zone

An Introduction To JBoss RichFaces | Eclipse Zone

If it's your first time to study JBoss RichFaces, here is a good place to start.

RichFaces for NetBeans IDE 6.1 (Part 1)

RichFaces for NetBeans IDE 6.1 (Part 1): "RichFaces for NetBeans IDE 6.1"
It also work for 6.5

2008/12/21

2008 台北馬拉松

2008/12/13

2008/12/11

Troubleshooting on Tomahawk JSCook Menu

http://wiki.apache.org/myfaces/JSCook_Menu

Check Notes and Known issues.
I had faced this issue Place of Menu tag in relation to Forms:
Menus must be placed inside forms starting with Tomahawk 1.1.3.
With regard to how to do configuration in web.xml, please check http://myfaces.apache.org/tomahawk/extensionsFilter.html

2008/12/10

java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapping missing. JSF pages not covered.

Error Message
1
2
3
4
5
6
7
java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapping missing. JSF pages not covered. Please see: http://myfaces.apache.org/tomahawk/extensionsFilter.html
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.throwExtensionsFilterMissing(AddResourceFactory.java:389)
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.checkEnvironment(AddResourceFactory.java:349)
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.getInstance(AddResourceFactory.java:279)
    at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.addResourcesToHeader(HtmlJSCookMenuRenderer.java:404)
    at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.encodeBegin(HtmlJSCookMenuRenderer.java:363)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)


Solution
If you are using servlets 2.4, you cannot do a jsp:forward or request.getDispatcher().forward to any page, because the extensions filter is not executed. Instead you may want to try with a response.sendRedirect(). Therefore, I need to modify to response.sendRedirect("template-client.jsf");