Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Introduction
In this tutorial we will create a simple session EJB and a client web application using
eclipse IDE along with Lomboz plug in and XDoclet. This application, while simple,
provides a good introduction to EJB development and some of the Web development
tools available.
· Environment
J2SDK 1.4.2
http://java.sun.com/
Eclipse 3.1
http://www.eclipse.org/
JBoss 4.0.2
http://www.jboss.org/
XDoclet 1.2.3
http://xdoclet.sourceforge.net
Lomboz 3.1RC2
http://lomboz.objectweb.org/
· Installation
Install JDK (in D:j2sdk1.4.2_04)
2. Set up the installed runtime for server in eclipse (Windows -> Preferences ->
Server -> Installed Runtimes)
3. Set up Xdoclet in eclipse (Windows -> Preferences -> J2EE Annotations ->
XDoclet)
4. Set up the ejbdoclet for JBoss in eclipse (Windows -> Preferences -> J2EE
Annotations -> Xdoclet -> ejbdoclet)
· Creating a Session Bean
1. Open the J2EE perspective in eclipse (Windows -> Open Perspective -> Other ->
J2EE)
2. Create a new EJB Project from the Project Explorer (EJB Projects -> New -> EJB
Project)
XDoclet is an extended Javadoc Doclet engine. It's a generic Java template engine
that lets us create custom Javadoc @tags and based on those @tags generate
source code or other files (such as deployment descriptors in xml form). XDoclet
supports a set of common standard tasks such as web.xml or ejb-jar.xml
generation. It uses special JavaDoc @tags to define settings for each component.
For example, putting a @ejb.bean name="Hello" jndi-name="Hello"
type="Stateless" in HelloBean.java
We have to edit only the HelloBean.java. All others are automatically generated
and XDoclet will regenerate them each time we make a change to the HelloBean
class.
return "Hello..";
The XDoclet builder will start working again and update our classes. At the end
our projects will look like:
The highlighted classes HelloBean.java and HelloSession.java are server side classes and
Hello.java and HelloHome.java are public interfaces. These are the classes that will be
needed by all clients.
Ensure that the option “Automatically publish when starting server” is checked.
4. Look for console messages such as:
2. In the Project Explorer, right click on the HelloWeb dynamic web project and
Choose Properties...
3. In the Java buildpath, add the SimpleEJBTutorial project to the project references.
This will help allows us to compile against the latest ejb client classes in this web
project.
4. Create a new “test.jsp” under the HelloWebWebContent directory.
5. Open test.jsp in the JSP source page editor.
6. Add the following lines in the “body” of test.jsp
<%
try{
hello = home.create();
}catch(Exception exception)
%>
Conclusion
In this tutorial we learned how to configure Eclipse to work with XDoclet and create
a J2EE EJB project that has a Session Bean. We created a client Web application. This
application, while simple, provides a good introduction to EJB development and
some of the Web development tools available.