Welcome Guest   Login   Mar 19, 2024
Registered Users
Login
Sign-up

 

 


Fedora & Vista Blog


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


Old Articles
Mastering Enterprise JavaBean 3.0 book for SCBCD Certification
Simplest JPA Example
EJB 2.1 example from Mastering Enterprise JavaBean 3.0 book.
No new edition for Head First EJB - SCBCD 5 book

Suggestions/Comments/Views
Name:
E-Mail:
(Only admin can see)
Comments:

 

 

My New Blog

My Award winning Whitepaper

Contradicting Light
My Personal Blog


Trace Mobile Location



My Book Reviews
 




Tech Jokes Worth Reading

 
Top
Home
www.deepjava.com 1999-2017 (C) Developed and maintained by D-Kay Consultancy