2008年9月11日星期四

RandomAccessFile notes

/**
* Write contents to txt file using "RandomAccessFile "
*
*/

String filepath = "E:\\wwwroot\\tmp\\testRandomAccreeFile.txt";
RandomAccessFile f = new RandomAccessFile(filepath,"rw");
f.seek(7 * 7 - 2);
String toWrite = "Helloo";

// not work, it will output one white space after one char.
//f.writeChars( toWrite );

// not work, it will output one white space and a new line
// before toWrite after writing
// f.writeUTF( toWrite );

// This is the right solution
f.write(toWrite.getBytes());

f.close();

2008年9月9日星期二

jadclipse sometimes does not work.

jadclipse works for a time, and sometimes fails to work, and can not decompile java class.
In fact we can make it work again. I restart eclipse, and it's OK.

2008年9月4日星期四

import java.util.Date & java.sql.Date


Import wrong class,


java.util.Date should be imported, but java.sql.Date was imported in entity class,
so java.lang.IllegalArgumentException is thrown,
btw, the debug point is in:

com.mycom.db.dao.CommDbOperTool$CustomRowMap.mapRow(CommDbOperTool.java:71)


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
com.mycom.webapp.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:42)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
com.mycom.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:63)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


root cause

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
com.mycom.db.helper.annota.AnnotaEntityOper.doSet(AnnotaEntityOper.java:325)
com.mycom.db.helper.annota.AnnotaEntityOper.createObjByRs(AnnotaEntityOper.java:124)
com.mycom.db.dao.CommDbOperTool$CustomRowMap.mapRow(CommDbOperTool.java:71)
org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:600)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:538)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:588)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:617)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:625)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:657)
com.myapp.db.dao.AccountCashingDao.getAccountCashingBySiteUserID(AccountCashingDao.java:49)
com.mycom.myapp.user.manager.AccountManager.getAccountCashingBySiteUserID(AccountManager.java:158)
com.mycom.myapp.user.manager.AccountManager$$FastClassByCGLIB$$ab87176b.invoke()
net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:694)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
com.mycom.myapp.user.manager.AccountManager$$EnhancerByCGLIB$$cdf0dc72.getAccountCashingBySiteUserID()
com.mycom.myapp.webapp.action.AccountCashingAction.listCashing(AccountCashingAction.java:85)
com.mycom.myapp.webapp.action.AccountCashingAction.execute(AccountCashingAction.java:54)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
com.mycom.webapp.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:42)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
com.mycom.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:63)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


root cause

java.lang.IllegalArgumentException
sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)
java.lang.reflect.Field.set(Unknown Source)
com.mycom.db.helper.annota.AnnotaEntityOper.doSet(AnnotaEntityOper.java:322)
com.mycom.db.helper.annota.AnnotaEntityOper.createObjByRs(AnnotaEntityOper.java:124)
com.mycom.db.dao.CommDbOperTool$CustomRowMap.mapRow(CommDbOperTool.java:71)
org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:600)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:538)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:588)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:617)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:625)
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:657)
com.myapp.db.dao.AccountCashingDao.getAccountCashingBySiteUserID(AccountCashingDao.java:49)
com.mycom.myapp.user.manager.AccountManager.getAccountCashingBySiteUserID(AccountManager.java:158)
com.mycom.myapp.user.manager.AccountManager$$FastClassByCGLIB$$ab87176b.invoke()
net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:694)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
com.mycom.myapp.user.manager.AccountManager$$EnhancerByCGLIB$$cdf0dc72.getAccountCashingBySiteUserID()
com.mycom.myapp.webapp.action.AccountCashingAction.listCashing(AccountCashingAction.java:85)
com.mycom.myapp.webapp.action.AccountCashingAction.execute(AccountCashingAction.java:54)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
com.mycom.webapp.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:42)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
com.mycom.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:63)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.13

2008年8月26日星期二

STX Transform Notes

I tries to transform xml with Joost(STX), but I found that sometimes the child nodes cannot be matched and transformed.
Finally I found the problem was tied with the XML namespace, and made the transform working in this way, please notice the prefix "myns" both in root node and child nodes:

Source XML:

<RootNode xmlns="http://.... " >
<ChildNode>
....

STX:
<stx:transform version="1.0"
xmlns:stx="http://stx.sourceforge.net/2002/ns"
xmlns:myns="http://www.../" >

<stx:template match="myns:RootNode">
...
<stx:template>

<stx:template match="myns:ChildNode">
...
<stx:template>

How to output new line in result xml in STX transform

I'm new to professional xml develop and boring the transformed result xml is always one large line those days.
Now I found the way out,

"<stx:text>&# xA;</stx:text>" is the solution!
(please remove the white space, google can not post xml code?)

2008年8月11日星期一

发现 Foxmail 的一个逻辑 BUG

今天网络情况不咋样, 开个网页经常打不开.
用 Foxmail 一直收不到信.
没有设置让foxmail记住密码.
一旦网络坏掉而没有成功收信, 下次收信时, foxmail会再次询问密码.

我认为这是一个很严重的逻辑问题, 应该在密码错误的情况下才应该询问密码, 而不是在网络出错的情况下.

I'm back

习惯了用雅虎邮箱来做一切事, 现在又回归到这个google帐号.