Wednesday 17 October 2007

ปัญหา configurationException เมื่อใช้งาน EJB

คราวที่แล้วผมได้พูดถึง error ที่เกิดขึ้นบนฝั่งของ JBoss ไปแล้ว คราวนี้เราจะมาดูในฝั่งของ WebSphere 6 กันบ้างนะครับ (ถ้าสังเกตจะพบว่าผมจะทดสอบกับ JBoss และ WebSphere เป็นส่วนใหญ่ เนื่องจากที่เครื่องผมติดตั้ง Application Server ทั้งสองตัวนี้อยู่แล้วพอดี แต่ถ้ามีเพื่อน ๆ สอบถามเข้ามามาก ผมก้อจะไปหาคำตอบมาเพิ่มเติมให้นะครับ อย่าพึ่งคิดว่าผมยึดติดกับสองค่ายนี้)

หลังจากที่เราเขียน Session Bean ที่ทำการติดตั้งไว้บน WebSphere Server 6 เรียบร้อย รวมทั้งเช็ต EJB client library สำหรับเรียก EJB ครบ พอเราเริ่มทดสอบการเรียก bean ขึ้นมาจริง ๆ ด้วย cilent application ที่เราเขียนขึ้น กับเจอ error ดังนี้

14 Oct 2007 14:25:52 com.ibm.ws.naming.util.CommonHelpersWARNING: jndiproviderProperties
14 Oct 2007 14:25:53 com.ibm.ws.naming.util.CommonHelpersWARNING: jndiproviderProperties14 ต.ค. 2550 14:25:53 com.ibm.websphere.naming.WsnInitialContextFactoryWARNING: noInitCtxFactoryImpljavax.naming.ConfigurationException: The property com.ibm.ws.naming.wsn.factory.initial is not set. The most likely cause is that the jar which
contains the file com/ibm/websphere/naming/jndiprovider.properties cannot be found by the class loader. at com.ibm.websphere.naming.WsnInitialContextFactory.init_implClassCtor(WsnInitialContextFactory.java:194) at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(WsnInitialContextFactory.java:112) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:675) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:257) at javax.naming.InitialContext.init(InitialContext.java:233) at javax.naming.InitialContext.<init>(InitialContext.java:209) at sample.MyTest1Util.lookupHome(MyTest1Util.java:20) at sample.MyTest1Util.getHome(MyTest1Util.java:54) at Main.main(Main.java:17)


เมื่อพบ error นี้ นั่นหมายความว่าเราไม่ได้ กำหนดค่า library ที่ ว่า nameclient.jar นั่นเอง library ตัวนี้จะอยู่ใน Application Server ดังนี้ <WebSphere Home>/lib/nameclient.jar เมื่อ add library เสร็จ error ตัวนี้ก้อจะหายไป เป็นอันเรียบร้อย

No comments: