วันอังคารที่ 2 กันยายน พ.ศ. 2551

Basick ZK Framework ตอนที่ 1 Config ZK

สามารถ Download ได้ ที่นี่
เป็น Ajax Framework ที่ไม่ต้องมานั่งเขียน Java script น่ะครับ หาข้อมูลเพิ่มเติมได่ที่หน้าเวบ

* สามารถใช้บน Websphere 6.x ได้ครับ ลองมาแล้ว Config เหมือนกันเลย

ตอนนี้จะบอกว่าเราต้อง Config อะไรเพิ่มใน web.xml บ้างนะ่ครับ ที่จริงก็อ่านได้ตามเวบเหมือนกัน ผมรวบรวมไว้จะได้ค้นง่ายๆ

เพิ่มส่วนของ Listener ด้วย

<listener>
<description>Used to cleanup when a session is destroyed</description>
<display-name>ZK Session Cleaner</display-name>
<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
</listener>


ต่อไปเพิ่มในส่วยของ Servlet

<servlet>
<description>ZK loader for ZUML pages</description>
<servlet-name>zkLoader</servlet-name>
<servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
<init-param>
<param-name>update-uri</param-name>
<param-value>/zkau</param-value>
</init-param>
<load-on-startup>1</load-on-startup> สำหรับตรงนี้ ถ้า Config บน Websphere อาจจะต้องลองเปลี่ยนเลขดูน่ะครับ ถ้ามันยังไม่ได้
</servlet>

<servlet>
<description>The asynchronous update engine for ZK</description>
<servlet-name>auEngine</servlet-name>
<servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
</servlet>


หลังจากนั้นก็เพิ่ม Servlet-Mapping

<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zul</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>auEngine</servlet-name>
<url-pattern>/zkau/*</url-pattern>
</servlet-mapping>


เป็นอันเสร็จครับ ก็จะทำให้ใช้ Zk Framework ได้ล่ะ


ลองเทสโดยการเขียน index.zul แบบนี้ดูครับ ว่ามันขึ้นหน้าจอหรือเปล่า

<window title="My First window" border="normal" width="200px">
Hello, World!
</window>

วันอังคารที่ 29 กรกฎาคม พ.ศ. 2551

Config Servlet Cache Instances [On Websphere 6.0-6.1]

จะสอนวิธี Config Servlet Cache ของ Websphere ซึ่งมีวิธี 3 แบบครับ

ฮธิบายก่อน Servlet Cache คือ การเก็บค่าไว้โดยที่ไม่ต้องทำการประมวณผลใหม่ในกรณีที่เราเข้ามาด้วย parameter เดิมนะครับ (ที่จริงมีกำหนดหลายแบบ ผมขอบอกเฉพาะที่เป็น Parameter นะครับ) เช่น สมมตผมกำหนด ว่าให้ Servlet SampleCache ไว้เป็น Servlet Cache แล้วกำหนด Parameter ให้ productId เป็นไว้ เมื่อเราเข้าหน้าเวบด้วย productId=1 ครั้งแรกจะยังเข้า Servlet อยู่ แล้วครั้งต่อๆ ไปพอเราลอง Refresh หน้าดูแล้วจะไม่มีการเข้าไปใน Process ของ Servlet อีกครับ จะใช้ค่าเดิมที่เราเข้าไปครั้งแรกเลย (สามารถกำหนด Timeout ได้ครับ)

เราต้อง Config ให้ Websphere ใช้งาน Servlet Cache ก่อนโดย

  1. ไปที่ Servers --> Application Servers
  2. แล้วเลือก Server ที่เราต้องการจะ Config Servlet Cache
  3. ดูที่ทางขวา จะมี Container Settings ให้เลือกที่ Web Container Settings --> Web Container
  4. พอกดเข้าไปจะเห็น Enable Servlet Caching แล้วติ๊ก
  5. พอทำเสร็จก็ Restart Server ครับ เป็นอัน Config Servlet Cache ให้ใช้งานได้ล่ะ

ต่อไปเรามา Config Servlet Cache ที่เครื่องเราต่อ (ผมใช้ Config จาก cachespec.xml) ตอนแรกเราจะต้องไปเอา cachespec.xml, cachespec.dtd มาก่อน โดยจะอยู่ที่ xxx\base_v6\properties ครับ แล้ว Copy มาไว้ที่ Project ของเรา ที่ Path --> WEB-INF


แบบที่ 1 จะเป็นการ Config ให้ดูที่ Path

<cache-entry>
<class>servlet</class> --> กำนหดให้เป็นชนิด Servlet
<name>/ProductDisplay</name> --> Servlet Path ชื่อนี้
<cache-id>
<component id="productId" type="parameter"> --> กำหนดให้ Parameter ที่ส่งมาถ้ามีตัวนี้ ซ้ำ จะไม่ทำงานซ้ำ
<required>true</required> --> จำเป็นจะต้องมี Parameter ตัวนี้ส่งมาหรือเปล่า
</component>
<timeout>180</timeout> --> กำหนด Timeout ของ Servlet Cache
</cache-id>
</cache-entry>

แบบที่ 2 กำหนดที่ตัว Class เลย

<cache-entry>
<class>servlet</class>
<name>com.webpage.servlet.ProductDisplay2.class</name> --> บอกว่าเป็น Servlet Class ไหน
<cache-id>
<component id="productId" type="parameter">
<required>true</required>
</component>
<timeout>300</timeout>
</cache-id>
</cache-entry>


แบบที่ 3 จะคล้ายๆ กับแบบแรก แต่จะใช้ Servlet Cache ของ Application Server เลย

<cache-instance name="cache/servlet/sample"> --> กำหนด JNDI Name ของ Servlet Cache
<cache-entry>
<class>servlet</class>
<name>/ProductDisplay3</name>
<cache-id>
<component id="productId" type="parameter">
<required>true</required>
</component>
<timeout>180</timeout>
</cache-id>
</cache-entry>
</cache-instance>


วิธี Config Servlet Cache ของ Application Server

  1. ให้ไปที่ Resources --> Cache instances --> Servlet cache instances
  2. คลิกเข้ามาเสร็จ ก็เลือก New
  3. แล้วกำหนดชื่อ JNDI Name ให้เป็นชื่อเดียวกับ ที่เรากำหนดใน cachespec.xml
  4. Save แล้วก็ Restart Server เป็นอันเสร็จ


Reference
http://www.webagesolutions.com/knowledgebase/waskb/waskb008/index.html

วันศุกร์ที่ 4 กรกฎาคม พ.ศ. 2551

Data store tables
























Table namePurpose
SIBOWNEREnsure exclusive access to the data store by an active messaging engine
SIBCLASSMAPCatalogs the different object types in the data store
SIBLISTINGCatalogs the SIBnnn tables
SIBXACTSMaintain the status of active two-phase commit transactions
SIBKEYSAssign unique identifiers to objects in the messaging engine
SIBnnn, where nnn is a numberContain persisted objects such as messages and subscription information

These
tables hold both persistent and nonpersistent objects, using separate tables
for the different types of data, according to the following convention:


  • SIB000 contains information about the structure of the data in the other
    two tables

  • SIB001 contains persistent objects

  • SIB002 contains nonpersistent objects that have been saved to the data store to reduce the messaging engine memory
    requirement





Reference

Data store tables

วันศุกร์ที่ 9 พฤษภาคม พ.ศ. 2551

วิธีการสร้าง Profile ใหม่บน RAD 6.0

C:\IBM\WAS 6.0\profiles\AppSrv01\installedApps\naphacharaNode01Cell\DefaultApplication.ear\DefaultWebApplication.war\WEB-INF

เป็นวิธีการสร้างอย่างง่ายๆ ครับ เพราะมันไม่ยากแค่คลิกๆ แล้วก็จำบางอันว่าให้เอาออกแค่นั้นเองครับ โดยทำได้ดังนี้ครับ

  1. ไปที่ Window --> Preferences
  2. ต่อไป ไปที่ Server เลือก Websphere

  3. มันจะขึ้นหน้า Websphere แล้วเลือกที่ Create Profile

  4. รอสักพัก จะขึ้นหน้าดังรูป


  5. แล้วก็ Next จะให้เรากรอก Profile Name





  6. พอทำข้อ 5 เสร็จ ก็ Next จะเป็นการสร้าง Directory ของ Profile ไว้ว่าจะเอาไว้ที่ไหน






  7. Next ต่อไปจะเป็นการตั้งชื่อ Node กับ HostName






  8. Next จะเป็นการกำหนด Port ต่างๆ ของ Websphere (Default เลยครับ)






  9. Next หน้านี้สำคัญครับ ให้ติกเอา Run the Application Server process as a Windows Service ออกนะครับ






  10. Next จะเป็นสรุปว่าต้องที่เรา Config ถูกต้องไหม ต้องใช้พื้นที่เท่าไร






  11. Next จะ Install Profile ใหม่ลง






  12. พอเสร็จแล้วมันจะบอก Finish แล้วเราก็จะสามารถ Create Server ลงที่ Profile ใหม่ได้เลย ทำจากหน้า Server ใน Rad 6.0 เลยครับ ง่าย






วันอังคารที่ 6 พฤษภาคม พ.ศ. 2551

SQL ไว้สำหรับนับจำนวน Cursor ที่เิปิดใน Oracle ครับ

เอาไว้สำหรับดูว่ามี Cursor อะไรเปิดอยู่บ้างใน Oracle ครับ

select sid, sql_text from v$open_cursor order by sid, sql_text


Reference
http://forum.java.sun.com/thread.jspa?threadID=135291

วันศุกร์ที่ 2 พฤษภาคม พ.ศ. 2551

Path Log ของ XA Datasource

Path จะอยู๋ประมาณนี้น่ะครับ จะอยู๋ใน tranlog น่ะครับในแต่ละ Profiles ซึ่งสาเหตุที่เราไปลบเพราะว่า บางทีWebsphere จะมี Log Error ค้างอยู่ใน Server ซึ่งที่ผมเห็นจะเกิดจาก XA Datasource น่ะครับ แล้วมันจะค้างตลอดใน Server เราเลยต้องตามไปลบ ไม่งั้นมันก็จะขึ้นตลอดน่ะครับ


จะขึ้นประมาณข้างล่างนี้น่ะครับ
[5/2/08 15:51:43:720 ICT] 00000050 RegisteredRes E WTRN0063E: An illegal attempt to commit a one phase capable resource with existing two phase capable resources has occurred.
[5/2/08 15:51:43:723 ICT] 00000050 RegisteredRes E WTRN0086I: XAException encountered during prepare phase for transaction 00000119A8D46B1C000000010004EC456280C5DF303AAF4EFAC6AC2CC0E8082A1BD2474A00000119A8D46B1C000000010004EC456280C5DF303AAF4EFAC6AC2CC0E8082A1BD2474A00000001. Local resources follow.
[5/2/08 15:51:43:725 ICT] 00000050 RegisteredRes E WTRN0089I: XATransactionWrapper@ cdc2b3 XAResource: com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@1539da0 enlisted: true mcWrapper.hashCode()31227578: Vote: commit.

วิธีแก้ว่าไม่สามารถใช้ Datasource ที่สร้างใหม่ได้

คือเวลาสร้างเสร็จแล้วลอง Test Connection แล้วไม่สามารถที่จะ Test ผ่านน่ะครับ จะขึ้นประมาณว่า
invalid arguments in callDSRA0010E: SQL State = null, Error Code = 17,433
แบบนี้ ผมได้ข้อมูลตามลิงค์ข้างล่างน่ะครับ

เหตุผลจากคุณ Ken Hygh
1) the application isn't closing connections and is thus 'leaking' them.
2) the database doesn't have enough 'listeners' for the number of
connections you're trying to open. This generally happens in a clustered
environment, where the database must support #Connections x #Servers.
3) there's a database call that's taking a very long time, and
eventually every configured connection gets into this call and until one
completes, no other threads can get a connection.

วิธีแก้ง่าย ก็ Restart Server นั้นครับ ก็จะใช้งานได้เลย

Reference
http://www.ibm.com/developerworks/forums/message.jspa?messageID=13762630