วันพฤหัสบดีที่ 16 เมษายน พ.ศ. 2552

JBoss5 JNDI

เพิ่งจะได้ลอง JBoss 5.0.1 หลังจากที่ลอง JBoss 5.0 ตั้งแต่วันแรกที่ออก(อุตส่าห์รอคอย)
ใน JBoss 5.0 พบว่าเขียน Test client (java class with main method to call ejb service) เปลี่ยน namming ให้ตายก็ lookup ไม่เจอสักทีเสียเวลาเป็นวัน เลิกเลย

หลังจากเห็น JBoss 5.0.1 ออกมาเกือบสองเดือนก็ยังไม่ได้เทส วันนี้ว่างๆเลยขอลองซะหน่อย
ปรากฏว่าเต่นเต๋นเต้น ตอน deploy เสร็จเห็นเลยว่ามี JNDI อะไรบ้างที่ binding เข้ากับ Global JNDI เลย
23:30:20,632 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:

MyPrint/remote - EJB3.x Default Remote Business Interface
MyPrint/remote-test.PrintRemote - EJB3.x Remote Business Interface


เข้าไปดูใน JMX Console ก็เห็นเหมือนเวอร์ชั่น 4.2 ด้วย(ดีใจไม่ต้องเสียเวลางม)
+- MyPrint (class: org.jnp.interfaces.NamingContext)
| +- remote-test.PrintRemote (class: Proxy for: test.PrintRemote)
| +- remote (class: Proxy for: test.PrintRemote)


ตัว Test client ก็ง่ายๆเหมือนเวอร์ชั่น 4.2 เลย

public class PrintClient {
public static void main(String[] args) {
try {
Properties prop = new Properties();
prop.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
prop.setProperty("java.naming.provider.url","jnp://localhost:1099");
prop.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

InitialContext ctx = new InitialContext(prop);
PrintRemote print = (PrintRemote)ctx.lookup("MyPrint/remote");
print.display();
} catch (Exception e) {
e.printStackTrace();
}
}
}

จบเรื่องคาใจไปอีกเรื่อง งมใน mail ก็เห็นคนบ่นกัน ว่าแล้วว่ามันต้องแก้

ไม่มีความคิดเห็น:

แสดงความคิดเห็น