OS : Windows 7
Python : Python 3.5
Tool : Python IDLE , Notepad++
Status :
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xab in position 0: invalid start byte
Cause :
Notepad++ saves files in ANSI as the default encoding.
Solution :
Changes the encoding for hello.txt : convert to UTF-8 (No BOM)
蟲蟲日誌
2016年3月10日 星期四
2014年10月3日 星期五
Richfaces 3.3.2 : ajax /rerender partially not full support in IE11
Status :
partial rerendering is abnormal for h:inputTextarea, rich:modalPanel, and rich:calendar.
The following is an image of abnormal h:inputTextarea ,
Reason : Richfaces 3.3.2 ajax not support IE11 because of User-agent string changes
(使用者代理字串變更)
Solution : modifies AJAX.js in the richfaces-impl-3.3.2.GA.jar ,
step 2 : adds ie11 checking to Sarissa._SARISSA_IS_IE and Sarissa._SARISSA_IS_IE9 :
Sarissa._SARISSA_IS_IE = (document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1) || (navigator.userAgent.toLowerCase().indexOf("like gecko") > -1 && navigator.userAgent.toLowerCase().indexOf("11.") > -1);
Sarissa._SARISSA_IS_IE9 = Sarissa._SARISSA_IS_IE && (parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+5))) >= 9 || (navigator.userAgent.toLowerCase().indexOf("like gecko") > -1 && navigator.userAgent.toLowerCase().indexOf("11.") > -1);
Reference :
http://ruleoftech.com/2013/patching-richfaces-3-3-3-ajax-js-for-ie9
https://issues.jboss.org/browse/RF-13443
partial rerendering is abnormal for h:inputTextarea, rich:modalPanel, and rich:calendar.
The following is an image of abnormal h:inputTextarea ,
(使用者代理字串變更)
Solution : modifies AJAX.js in the richfaces-impl-3.3.2.GA.jar ,
I did the same step to Richfaces 3.3.2 , and it works fine.
step 2 : adds ie11 checking to Sarissa._SARISSA_IS_IE and Sarissa._SARISSA_IS_IE9 :
Sarissa._SARISSA_IS_IE = (document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1) || (navigator.userAgent.toLowerCase().indexOf("like gecko") > -1 && navigator.userAgent.toLowerCase().indexOf("11.") > -1);
Sarissa._SARISSA_IS_IE9 = Sarissa._SARISSA_IS_IE && (parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+5))) >= 9 || (navigator.userAgent.toLowerCase().indexOf("like gecko") > -1 && navigator.userAgent.toLowerCase().indexOf("11.") > -1);
Reference :
http://ruleoftech.com/2013/patching-richfaces-3-3-3-ajax-js-for-ie9
https://issues.jboss.org/browse/RF-13443
jQuery conflicts with Richfaces's modal panel -- rich:modalPanel, rich:calendar
Status :
While the jQuery added to a page, rich:modalPanel and rich:calendar do not work.
Solution : run jQuery.noConflict
<script type="text/javascript" src="scripts/jquery-1.5.1.min.js">
</script>
<script type="text/javascript">
jQuery.noConflict();
</script>
Reference :
http://forum.jquery.com/topic/problem-with-jquery-1-5-2-min-js-and-jsf-rich-modalpanel
While the jQuery added to a page, rich:modalPanel and rich:calendar do not work.
Solution : run jQuery.noConflict
<script type="text/javascript" src="scripts/jquery-1.5.1.min.js">
</script>
<script type="text/javascript">
jQuery.noConflict();
</script>
Reference :
http://forum.jquery.com/topic/problem-with-jquery-1-5-2-min-js-and-jsf-rich-modalpanel
2014年10月1日 星期三
Richfaces 3.3.2 : file upload failed in IE11
Status :
transfererror happen
Exception :
Caused by: java.lang.NullPointerException at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:138)
Trace :
1. source code :
2. html : (F12 : Developer tool)
a. RichFaces Live Demo : work fine : <h:form> ...... </h:form>
<form name="j_id353" id="j_id353" action="/richfaces-demo/richfaces
/fileUpload.jsf;jsessionid=8FCE14B6E3145970C161C54903BCEBDB"
enctype="application/x-www-form-urlencoded" method="post">
.....
</form>
b. my page : not work : <a4j:form id="uploadForm"> ...... </a4j:form>
<form name="uploadForm" id="uploadForm" action="/mh/a/admin/home.fcs"
method="post" target="">
.....
</form>
Solution : <a4j:form> does not add "enctype" attribute automatically .
The following 3 methods can solve this problem:
* uses <h:form>
* uses <h:form enctype="multipart/form-data">
* uses <a4j:form enctype="multipart/form-data">
transfererror happen
Exception :
Caused by: java.lang.NullPointerException at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:138)
Trace :
1. source code :
134 MultipartRequest multipartRequest = MultipartRequest.lookupRequest(context, uid); 135 136 boolean isFlash = (requestParameterMap.get("_richfaces_send_http_error") != null); 137 138 List<UploadItem> fileList = multipartRequest.getUploadItems();
2. html : (F12 : Developer tool)
a. RichFaces Live Demo : work fine : <h:form> ...... </h:form>
<form name="j_id353" id="j_id353" action="/richfaces-demo/richfaces
/fileUpload.jsf;jsessionid=8FCE14B6E3145970C161C54903BCEBDB"
enctype="application/x-www-form-urlencoded" method="post">
.....
</form>
b. my page : not work : <a4j:form id="uploadForm"> ...... </a4j:form>
<form name="uploadForm" id="uploadForm" action="/mh/a/admin/home.fcs"
method="post" target="">
.....
</form>
Solution : <a4j:form> does not add "enctype" attribute automatically .
The following 3 methods can solve this problem:
* uses <h:form>
* uses <h:form enctype="multipart/form-data">
* uses <a4j:form enctype="multipart/form-data">
2013年4月24日 星期三
MySQLSyntaxErrorException: Unknown column 'y2_' in 'where clause'
Exception :
MySQLSyntaxErrorException: Unknown column 'y2_' in 'where clause'
出現時機 :
JPA : Criteria : Group by
Trace sql :
config file : jdbc.properties
property : hibernate.showsql=true
Description :
使用 Projections.groupProperty 時 , hibernate 產生的 sql 會自動設定 select alias y0_, y1_, y2_, ... , 依此類推 ; 所以如果為了可以以 map 取得 criteria results , 通常會在 projectionList.add 加入 alias , 但是如果 alias 與原 propery name 相同 , 又在 criteria有 add 同名 property 的 condition, 則 hibernate 產生的 sql 會以 yi_ alias 出現在 where clause 中 , 然後就會出現 Exception : Unkonwn column 'yi_' in 'where clause'
e.g.
Criteria criteria = this.getSession().createCriteria(DailyActiveCalendar.class);
ProjectionList projectionList = Projections.projectionList();
projectionList.add(Projections.groupProperty("room"), "r")
.add(Projections.groupProperty("aDate"), "date")
.add(Projections.groupProperty("active"), "active");
criteria.setProjection(projectionList);
[STDOUT] Hibernate:
select this_.room as y0_, this_.aDate as y1_, this_.active as y2_
from daily_active_calendar this_
group by this_.room, this_.aDate, this_.active
如果加入 where conditions :
criteria.add(Restrictions.eq("room", r))
.add(Restrictions.le("amount", r.getMaxSection()))
.add(Restrictions.lt("aDate", maxDate))
.add(Restrictions.eq("active", Boolean.TRUE));
[STDOUT] Hibernate:
select this_.room as y0_, this_.aDate as y1_, this_.active as y2_
from daily_active_calendar this_
where this_.room=? and this_.amount<=? and this_.aDate<? and y2_=?
group by this_.room, this_.aDate, this_.active
Solution :
在 where clause 中如果會使用到group by的項目時 , property name 與 alias 不要相同 , 例如上例中的 .add(Projections.groupProperty("active"), "active");
改為 .add(Projections.groupProperty("active"), "isActive");
[STDOUT] Hibernate:
select this_.room as y0_, this_.aDate as y1_, this_.active as y2_
from daily_active_calendar this_
where this_.room=? and this_.amount<=? and this_.aDate<? and active_=?
group by this_.room, this_.aDate, this_.active
MySQLSyntaxErrorException: Unknown column 'y2_' in 'where clause'
出現時機 :
JPA : Criteria : Group by
Trace sql :
config file : jdbc.properties
property : hibernate.showsql=true
Description :
使用 Projections.groupProperty 時 , hibernate 產生的 sql 會自動設定 select alias y0_, y1_, y2_, ... , 依此類推 ; 所以如果為了可以以 map 取得 criteria results , 通常會在 projectionList.add 加入 alias , 但是如果 alias 與原 propery name 相同 , 又在 criteria有 add 同名 property 的 condition, 則 hibernate 產生的 sql 會以 yi_ alias 出現在 where clause 中 , 然後就會出現 Exception : Unkonwn column 'yi_' in 'where clause'
e.g.
Criteria criteria = this.getSession().createCriteria(DailyActiveCalendar.class);
ProjectionList projectionList = Projections.projectionList();
projectionList.add(Projections.groupProperty("room"), "r")
.add(Projections.groupProperty("aDate"), "date")
.add(Projections.groupProperty("active"), "active");
criteria.setProjection(projectionList);
[STDOUT] Hibernate:
select this_.room as y0_, this_.aDate as y1_, this_.active as y2_
from daily_active_calendar this_
group by this_.room, this_.aDate, this_.active
如果加入 where conditions :
criteria.add(Restrictions.eq("room", r))
.add(Restrictions.le("amount", r.getMaxSection()))
.add(Restrictions.lt("aDate", maxDate))
.add(Restrictions.eq("active", Boolean.TRUE));
[STDOUT] Hibernate:
select this_.room as y0_, this_.aDate as y1_, this_.active as y2_
from daily_active_calendar this_
where this_.room=? and this_.amount<=? and this_.aDate<? and y2_=?
group by this_.room, this_.aDate, this_.active
Solution :
在 where clause 中如果會使用到group by的項目時 , property name 與 alias 不要相同 , 例如上例中的 .add(Projections.groupProperty("active"), "active");
改為 .add(Projections.groupProperty("active"), "isActive");
[STDOUT] Hibernate:
select this_.room as y0_, this_.aDate as y1_, this_.active as y2_
from daily_active_calendar this_
where this_.room=? and this_.amount<=? and this_.aDate<? and active_=?
group by this_.room, this_.aDate, this_.active
2013年4月22日 星期一
NetBeans : Build Successful , but "Cannot find symbol" keep showing
系統環境:
IDE: NetBeans7.0.1Error :
BUILD SUCCESSFUL
BUT , 出現許多紅色錯誤 "!" 號 : "Cannot find symbol " ,
雖然程式可以執行 , 但卻很困擾 , 很難分辨真假錯誤.
Solution:
刪除 (delete) netbeans 的 cache ---
Windows : %UserProfile%\.netbeans\7.0\var\cache
如果不放心 , 先將 \cache zip 作備份 , 再進行刪除 , 但是檔案很大 .
1. 先關閉 NetBeans (exit NetBeans)
2. 備份 \cache (backup \cache)
3. 刪除 \cache\* (delete \cache\*)
4. 重啟 NetBeans (restart NetBeans)
Reference :
http://stackoverflow.com/questions/8298854/what-is-causing-this-java-cannot-find-symbol-error
2011年6月14日 星期二
在同一台機器上執行多個 JBOSS server node/instance , 發生 ports 衝突
系統環境:
JBoss: JBoss_4.2.2.GA在同一台機器上執行多個 JBOSS server node/instanc:
JBoss 提供了 Binding Manager 服務 , 預設可同時執行 4 個 nodes.
JBoss 的設定文件:%JBOSS_HOME%\docs\examples\binding-manager\sample-bindings.xml,該文件默認情況下定義了4組不同的端口配置(port-default、port-01、port-02、port-03)
- 設置多個 server nodes :
- 修改 server nodes 的設定:[node-name]/conf/jboss-service.xml文件,配置Service Binding(默認註釋掉)如下:
<mbean code="org.jboss.services.binding.ServiceBindingManager"
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">ports-02</attribute>
<attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager /sample-bindings.xml</attribute>
<attribute name="StoreFactoryClassName">
org.jboss.services.binding.XMLServicesStoreFactory
</attribute>
</mbean>
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">ports-02</attribute>
<attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager /sample-bindings.xml</attribute>
<attribute name="StoreFactoryClassName">
org.jboss.services.binding.XMLServicesStoreFactory
</attribute>
</mbean>
錯誤狀況 : 如果同時執行 default-ports , ports-03的設置 , 會發生 ports 衝突
解決方案 : 修改 sample-bindings.xml --
- 在 sample-bindings.xml 中 ports-03 並沒有設定 remoting ,
- 將 default-ports 的 EJB3 Remoting Connector (line 197) 及 remoting connector (line 267 ) 的
區段複製到 ports-03 中 - 將複製到 ports-03 的區段中的 ports 3873 及 4446 改為 6873 及 7446
訂閱:
文章 (Atom)