Welcome Guest Login | | Sep 11, 2024 |
Home | SCJA | SCJP | SCJD | SCWCD | SCBCD | SCDJWS | SCEA | SCMAD | Downloads | Tutorials | About | Contact |
|
EJB 2.1 example from Mastering Enterprise JavaBean 3.0 book.
Example mentioned in Chapter 2 of Mastering Enterprise JavaBean 3.0 is incomplete. As per today’s standards, we don’t get reference implementation of Java Enterprise Edition, but we get Glassfish server from Sun along with NetBeans.You can code all the files in NetBeans 6.8 as mentioned in chapter 2 of Mastering Enterprise JavaBean 3.0. It requires some additional files. 1. Add the Glassfish specific deployment descriptor sun-ejb-jar.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd"> <sun-ejb-jar> <enterprise-beans> <name>HelloBean</name> <ejb> <ejb-name>HelloWorldEJB</ejb-name> <jndi-name>HelloHome</jndi-name> </ejb> </enterprise-beans> </sun-ejb-jar> 2. create a new web application for client and update JSP with this. <% Context ctx = new InitialContext(); Object obj = ctx.lookup("HelloHome"); HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class); Hello hello = home.create(); out.println(hello.hello()); hello.remove(); %> Do not create client as mentioned in the book, since you wont be able to reach out to JNDI from rich application. Posted by: scbcd
|
My New BlogMy Award winning Whitepaper
Contradicting Light
My Personal Blog |
www.deepjava.com 1999-2024 (C) Developed and maintained by D-Kay Consultancy
|