Java EE 5.
0 App Development on
Geronimo simplified using Eclipse
Shiva Kumar H.R.
IBM India Software Labs, Bangalore
shivahr@[Link] / shivahr@[Link]
Agenda
• Apache Geronimo - An Introduction
• Eclipse & Web Tools Platform
– Eclipse - Introduction, Java Development Tools
– Web Tools Platform, Geronimo Eclipse Plug-in
• Hands-on Exercises - 1
– IDE Setup
– Start Geronimo server
– Create a new Web application with a single JSP
– Deploy it on to Server
– Make changes to the Web application and Redeploy
– Undeploy Web application
– Stop Geronimo Server
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Agenda
• Apache Geronimo - An Introduction
• Eclipse & Web Tools Platform
– Eclipse - Introduction, Java Development Tools
– Web Tools Platform, Geronimo Eclipse Plug-in
• Hands-on Exercises - 1
– IDE Setup
– Start Geronimo server
– Create a new Web application with a single JSP
– Deploy it on to Server
– Make changes to the Web application and Redeploy
– Undeploy Web application
– Stop Geronimo Server
Apache Geronimo
• Open source J2EE/Java EE
Application Server developed by the
Apache Software Foundation.
• Brings together leading technologies
from the broad open source
community to support J2EE/Java EE.
[Link]
• Small footprint and highly
customizable.
Geronimo as a J2EE 1.4 compliant server*
*Source: IBM developerWorks article by author Sing Li
[Link]
Geronimo as a Java EE 5.0 compliant server*
*this slide needs to be updated
Agenda
• Apache Geronimo - An Introduction
• Eclipse & Web Tools Platform
– Eclipse - Introduction, Java Development Tools
– Web Tools Platform, Geronimo Eclipse Plug-in
• Hands-on Exercises - 1
– IDE Setup
– Start Geronimo server
– Create a new Web application with a single JSP
– Deploy it on to Server
– Make changes to the Web application and Redeploy
– Undeploy Web application
– Stop Geronimo Server
Eclipse & Web Tools Platform
An Integrated development environment
(IDE) for creating, deploying, and debugging
directly against Geronimo
Eclipse - Introduction
• Eclipse is an open source community
whose projects are focused on building an
extensible development platform,
runtimes and application frameworks for
building, deploying and managing
software across the entire software
lifecycle. [Link]
• Many people know it, and hopefully love
it, as a Java IDE but Eclipse is much
more than a Java IDE.
Java Development Tools*
• Code editing features - Code completion, Syntax coloring, Error
markers & Quick fixes, Automatic indent, Code folding (expand
and collapse).
• Code refactoring - Rename fields, methods, classes, interfaces, and
packages, as well as add get/set methods for fields.
• Source-level debugging - Set absolute/conditional breakpoints, Step
into method calls as well as over them, Jump out of methods, Run
to cursor.
• Visual code browsers like Project Explorer & Hierarchy views.
*Source: Eric J. Bruno’s article “NetBeans 4.1 & Eclipse 3.1”
[Link]
Eclipse Web Tools Platform*
• WTP supports J2EE/Java EE development.
• WTP extends Eclipse along two dimensions, namely
execution environments and artifact types.
• The execution environment dimension defines where
code runs.
– WTP extends Eclipse by adding servers as new execution
environments.
– Servers include both J2EE/Java EE and Database servers.
*Source: Arthur Ryman’s article “Eclipse: The Story of Web Tools Platform 0.7”
[Link]
Eclipse Web Tools Platform
• The development artifact dimension defines what developers create.
– New artifact types encountered in J2EE/Java EE development -
HTML, CSS, JavaScript, XHTML, JSP, XML, XSD, WSDL,
SQL, and all the J2EE/Java EE deployment descriptors.
– Each artifact type has associated with it builders, creation
wizards, syntax-aware editors, validators, semantic search
extensions, and refactoring support.
– Editors provide first-class programmer assistance such as code
completion, syntax coloring, error markers, and quick fixes.
Eclipse Web Tools Platform
• Key design goal of WTP - all of the functions that Eclipse users
have come to expect from Java source code will "just work" for
the new artifacts.
– For example, if I select a JSP, I can Run or Debug it.
– Similarly, the Debug command will run my J2EE/Java EE
server in debug mode and the standard Eclipse Debugger will
let me step through my JSP source code.
– My JSP editor will provide code completion for both JSP tags
and inlined Java scriptlets.
Geronimo Eclipse Plug-in
• Extends WTP’s server tools to add Apache Geronimo
as a new server type.
• Provides form based editors for Geronimo
Deployment Plans.
Eclipse WTP without Geronimo Eclipse Plug-in Eclipse WTP with Geronimo Eclipse Plug-in
Agenda
• Apache Geronimo - An Introduction
• Eclipse & Web Tools Platform
– Eclipse - Introduction, Java Development Tools
– Web Tools Platform, Geronimo Eclipse Plug-in
• Hands-on Exercises - 1
– IDE Setup
– Start Geronimo server
– Create a new Web application with a single JSP
– Deploy it on to Server
– Make changes to the Web application and Redeploy
– Undeploy Web application
– Stop Geronimo Server
IDE Setup
1. Download & Install Geronimo v2.0.1 from
[Link]
– “Geronimo 2.0.1 with Tomcat 6 (zip)” is used in this presentation.
2. Download and install WTP v2.0 all-in-one-sdk from
[Link]
– This includes Eclipse SDK v3.3, WTP v2.0 and WTP’s pre-requisites
namely EMF, GEF & DTP.
– “[Link]” is used in this
presentation.
3. Download and install Geronimo Eclipse Plug-in v2.0 as per the
instructions at [Link]
Finally start eclipse with “-clean” option (i.e. “eclipse -clean”) and switch
to “Java EE” perspective (Window -> Open Perspective -> Other ->
Java EE -> OK).
*JVM used: Sun JDK 1.5.0_11
Add Geronimo runtime into WTP
1. Click on the “Servers” tab at the bottom half of Eclipse window.
2. In the “Servers” view, right click and select “New->Server” from the
context menu.
3. In the “New Server” wizard that comes up, select “Apache Geronimo
v2.0 Server” and click “Next”.
4. Click “Browse” and specify the root directory of Apache Geronimo
v2.0.1 installation.
5. Click “Finish” to complete adding new server runtime. “Apache
Geronimo v2.0 Server at ..” should now appear in the “Servers” view.
Add Geronimo runtime into WTP
Step 3 Step 4
Start Geronimo server
1. In the “Servers” view select the server you just configured, right
click and select “Start” from the context menu.
2. You will be switched to the “Console” view while the server is
starting. Verify that you are switched back to the “Servers” view
and that the “State” of your server now says “Started”.
Create a new Web application
1. From the Eclipse menu select “File-
>New->Other”
2. Expand “Web” and select “Dynamic
Web Project” as shown. Click “Next”.
3. Enter “SimpleWeb” as the project name and make sure “Apache
Geronimo v2.0” is selected as the “Target runtime”.
4. Click “Next”. Make sure the “Geronimo Deployment” Project
Facet is selected.
5. Click “Next”. Accept the default web module settings and click
“Finish”.
Create a simple JSP
1. From the “Project Explorer”
view, expand “SimpleWeb”
project and select “WebContent”
folder. Right click and select
“New->JSP” from the context
menu as shown in fig.
2. Name the JSP “[Link]” and click “Finish”.
3. This brings up the JSP editor. Enter the text “Hello World”
between the <body> </body> HTML tags.
4. Type “Ctrl+S” to save the changes. Leave the editor window
open
Deploy the Web application
1. From the Eclipse menu select “Window->Web Browser” and then
select either “Internet Explorer” or “Firefox”. Without this step
Eclipse will use its Internal browser which takes up a lot of valuable
screen space within your Eclipse IDE.
2. From the “Project Explorer” view expand “SimpleWeb” and
“WebContent”.
3. Select “[Link]” , right click and select “Run As -> Run on Server”
4. Accept the defaults in the “Run on Server” dialog and click “Finish”.
5. A browser window should appear with the contents of “[Link]”.
Leave the browser window open.
Make changes to the Web
application and redeploy
1. Go back to the JSP editor and change “Hello World” to
something else (e.g. Hello Underworld).
2. Type Ctrl+S to save the changes.
3. Go to the “Servers” view and select your server. If the “Status”
column still* says “Republish”, right click and select “Publish”
from the context menu. Verify that the State of the server
changes to “Synchronized”.
4. Go back to the browser window that you used to test the JSP
initially and reload the page. Verify that the changes you made to
the JSP are reflected in the browser.
* WTP detects changes and invokes auto republish.
Undeploy web application
1. Go to the “Servers” view and select your server. Right click and
select “Add and Remove Projects” from the context menu
2. In the resulting dialog click on “Remove all” and then click on
“Finish”
Stop Geronimo server
1. Go back to the “Servers” view and select your server. Right click
and select “Stop” from the context menu.
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Application Overview &
Design
EJB sample application from Apache Geronimo v2.0 Samples
[Link]
Banking Application – Overall Architecture
Banking Application – Database Design
Database
Embedded
Apache Derby
Banking Application - Implementation
customer_info.jsp
JSP &
[Link] CustomerServiceServlet Servlets
[Link]
Stateless
BankManagerFacadeBean Session Bean
Customer Account JPA Entities
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Create & populate Database using
Admin Console
1. Start Geronimo server as before.
2. Open Admin Console, by right clicking on your server in Servers view and
selecting “Launch Geronimo Console”. Login with appropriate credentials*.
3. In “Console Navigation” portlet of Admin Console, click on “DB Manager”
under “Embedded DB”.
4. In “Create DB” textbox, type “BankDB” and click “Create”. This creates a
new Embedded Database by name “BankDB”. Make sure “Run SQL” view
displays the Result as “Database created: BankDB” (scroll down to see
Result).
5. Select “BankDB” next to “Use DB”, then copy the following SQL statements
into the textbox below and click “Run SQL”. This creates the required Tables
in “BankDB” and populates them. Make sure “Run SQL” view displays
Result as “SQL command/s successful”.
*default Username: system, Password: manager
Create & populate Database using
Admin Console
CREATE TABLE Customer(
customerId VARCHAR(255) PRIMARY KEY,
name VARCHAR(255));
CREATE TABLE Account(
accountNumber VARCHAR(255) PRIMARY KEY,
accountType VARCHAR(255),
balance DOUBLE,
customerId VARCHAR(255),
FOREIGN KEY (customerId) REFERENCES customer);
INSERT INTO Customer(customerId, name)
VALUES('12345','Panini');
INSERT INTO Account(accountNumber, accountType, balance, customerId)
VALUES('1234567890','Savings',1005.35,'12345');
INSERT INTO Account(accountNumber, accountType, balance, customerId)
VALUES('2345678901','Current',999.95,'12345');
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Create Database Connection Profile
1. Click on “Data Source Explorer” tab at the bottom half of Eclipse window.
2. Right Click on “Databases” and select “New” from the context menu.
3. In the “New Connection Profile” wizard that comes up, select “Derby
Embedded Database” and click “Next”.
4. Enter a “Name” for the connection profile, say “BankDBProfile”, and
click “Next”.
5. Click the ellipsis (…) button just
below “Select a driver from the
drop-down”, to create a new
Driver definition.
Create Database Connection Profile
6. In the “Driver Definitions” wizard that comes up, click “Add”.
7. In the “New Driver Definition” wizard that comes up, select “Database ->
Derby -> 10.2 -> Derby Embedded JDBC Driver”, make sure “Edit New
Driver Definition Immediately” is selected and click “OK”.
8. An “Edit Driver Definition” wizard comes up. Remove the default
“[Link]” by selecting it under “Driver File(s)” and clicking “Remove
Jar/Zip”.
9. Add “[Link]” shipped with Geronimo, by clicking on “Add
Jar/Zip” and then pointing to “<Geronimo
Home>\repository\org\apache\derby\derby\[Link]\ [Link]”.
10. Under “Properties” table, edit “Connection URL” value and change it to
“jdbc:derby:<Geronimo-Home>\var\derby\BankDB”, where <Geronimo-
Home> should be replaced with the path to your Geronimo root directory.
Change “Database Name” to “BankDB”. Finally Click “OK”.
Create Database Connection Profile
Embedded Derby’s Driver Definition
Create Database Connection Profile
11. Back in the “Driver Definitions” wizard, select the just added “Derby ->
10.2 -> Derby Embedded JDBC Driver” and click “OK”.
12. Back in the initial wizard, click “Finish”.
13. “BankDBProfile” should now appear under “Databases” in “Data Source
Explorer” view.
14. Right click on “BankDBProfile” and click “Connect”. If connect fails,
stop* Geronimo server and try again. Connect should now succeed.
*when Geronimo is already running, connecting to
its embedded database from outside might fail
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Create EJB project
1. From the Eclipse menu select “File->New->Other”
2. Expand “EJB” and select “EJB Project”.
3. Enter “BankEJB” as the project name & select “Apache Geronimo v2.0”
as the “Target runtime”. Click “Next”.
4. Select “Java Persistence” under “Project Facet” and un-select*
“Geronimo Deployment”. Make sure “EJB 3.0” & “Java 5.0” are
selected. Click “Next”. Click “Next” again.
5. In “JPA Facet” page, make sure “BankDBProfile” is selected as
“Connection”, then select “Annotated classes must be listed in
[Link]”, unselect “Create [Link]” and finally click “Finish”.
*selecting “Geronimo Deployment” will create “[Link]”
which is not required for EJB 3.0 (JPA) entities
Create JPA Entities
1. In the “Project Explorer” view right click on “BankEJB” project and select
“JPA Tools -> Generate Entities”.
2. Make sure “BankDBProfile” is selected as “Connection” and select “APP”
as the “Schema”. Click “Next”.
3. Specify “Package” name as “[Link]”.
Select both “Account” and “Customer” tables and click “Finish”. You will
see that JPA entities for those database tables are now created.
4. In “Project Explorer” view, expand “BankEJB -> ejbModule -> META-
INF” and double-click on “[Link]” to open it in an editor.
5. Replace* “[Link]” contents as shown next and press “Ctrl + S” to
save the changes. Press “Ctrl + W” to close the editor.
*In case you are unable to edit “[Link]” contents,
then try restarting your Eclipse!. Seems to be a bug.
Create JPA Entities
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="[Link]
xmlns:xsi="[Link] version="1.0"
xsi:schemaLocation="[Link]
[Link]
<persistence-unit name="BankPU">
<description>Entity Beans for Bank</description>
<provider>[Link]</provider>
<jta-data-source>BankPool</jta-data-source>
<non-jta-data-source>BankPool</non-jta-data-source>
<class>[Link]</class>
<class>[Link]</class>
<properties>
<property name="[Link]" value="false" />
</properties>
</persistence-unit>
</persistence>
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Create Session Bean Interface
1. In the “Project Explorer” view, right click on “BankEJB” project and
select “New -> Interface”.
2. Specify “Package” name as “[Link]” and
interface “Name” as “BankManagerFacadeLocal”. Click “Finish”.
3. Add following business methods inside the interface:
public Collection<Account> getAccountInformation(String customerId);
public Customer getCustomer(String customerId);
4. Press “Ctrl + Shift + O” to organize imports, “Ctrl + S” to save changes
and “Ctrl + W” to exit.
Create Session Bean
1. In “Project Explorer” view, right click on “BankEJB” project and select
“New -> Class”.
2. Specify “Package” name as “[Link]” and
class “Name” as “BankManagerFacadeBean”.
3. Click “Add” next to “Interfaces”, type & select
“BankManagerFacadeLocal” and click “OK”. Finally click “Finish”.
4. Add “@Stateless” annotation to “BankManagerFacadeBean” class as
below:
@Stateless
public class BankManagerFacadeBean implements BankManagerFacadeLocal {
5. Create a class variable for JPA’s EntityManagerFactory as below:
@PersistenceUnit(unitName="BankPU")
protected EntityManagerFactory emf;
Create Session Bean
6. Update business methods of Session Bean as below:
public Collection<Account> getAccountInformation(String customerId) {
Customer customer = getCustomer(customerId);
if(customer != null) {
return [Link]();
}
return null;
}
public Customer getCustomer(String customerId) {
EntityManager em = [Link]();
Customer customer = (Customer)[Link]([Link], customerId);
[Link]();
return customer;
}
7. Press “Ctrl + Shift + O” to organize imports, “Ctrl + S” to save changes & “Ctrl +
W” to close editor.
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Create Web Project & Servlet
1. Create a Dynamic Web project with name “BankWeb” as below: “File ->
New -> Other -> expand Web -> select Dynamic Web Project -> specify
Project name: BankWeb -> Next -> unselect* Geronimo Deployment ->
click Finish”.
2. In the “Project Explorer” view right click on “BankWeb” project and select
“New” -> “Servlet”.
3. Specify Java package as “[Link]” and
Class name as “CustomerServiceServlet”. Click “Next”.
4. In “URL Mappings” select “/CustomerServiceServlet” and click “Edit”.
Change the URL mapping to “/customer_info”. (JSPs that we will copy
next are using this URL and hence this change). Click “OK”.
5. Click “Finish”. “[Link]” will now be created and
elements for it will be added in “[Link]”.
*If Geronimo Deployment is selected, [Link] will be created.
In that case remember to update <context-root> inside [Link].
Create Web Project & Servlet
6. Add a class variable in the servlet to hold EJB reference to Session Bean as shown
below:
@EJB
private BankManagerFacadeLocal bm = null;
7. Update the doGet() method of CustomerServiceServlet as shown next:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String path = "/jsp/[Link]";
String customerCode = [Link]("customerCode");
Collection<Account> accountList = [Link](customerCode);
Customer customer = [Link](customerCode);
if (accountList != null && customer != null) {
[Link]("accountList", accountList);
[Link]("customerCode", customerCode);
[Link]("customerName", [Link]());
path = "/jsp/customer_info.jsp";
}
getServletContext().getRequestDispatcher(path).forward(request, response);
}
Create Web Project & Servlet
8. Forward call to doPost() method to doGet() as below:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
9. To resolve references to EJBs referred in doGet() method add “BankEJB”
project into the build path of “BankWeb” by “Right clicking on BankWeb
project -> Properties -> Java Build Path -> Projects -> Add -> select
BankEJB -> OK -> OK”.
10. Press “Ctrl + Shift + O” to organize imports, “Ctrl + S” to save changes &
“Ctrl + W” to close editor.
Copy JSPs into Web Project
1. In Project Explorer view, expand “BankWeb” and right click on “WebContent” folder
and click “Import”.
2. Expand “General” and select “File System”. Click “Next”.
3. Click “Browse” next to “From directory” and select the directory where you have
extracted “[Link]”*. Click “OK”.
4. On the left side of “Import” wizard, expand “Bank Example”, select & check “jsp”
folder.
5. Make sure “Into folder” says “BankWeb/WebContent”.
6. Click “Finish”. You will observe that a “jsp” folder is created in “WebContent”
directory of “BankWeb” project and following three files are copied inside of that
“jsp” folder: “[Link]”, “customer_info.jsp” and “[Link]”.
7. Import from File System can also be done by dragging “jsp” folder from “Windows
Explorer” and dropping it on “WebContent” directory of “BankWeb” project.
*Download [Link] from here
Update “[Link]”
1. In “Project Explorer” view expand “BankWeb” -> “WebContent” ->
“WEB-INF” and double click on “[Link]” to open it in an editor.
2. Update <welcome-file-list> element as below and press “Ctrl +S” to
save changes.
<welcome-file-list>
<welcome-file>jsp/[Link]</welcome-file>
</welcome-file-list>
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Create Enterprise Application Project
1. From Eclipse menu, select “File” -> “New” -> “Project…”.
2. Expand “J2EE” and select “Enterprise Application Project”. Click “Next”.
3. Specify “Project name” as “Bank”. Click “Next”. Click “Next” again.
4. In “J2EE Modules to Add to the EAR” page, select and check “BankEJB”
and “BankWeb” modules. Click “Finish”.
5. In “Project Explorer” view expand “Bank -> EARContent”. Right click on
“META-INF” and select “New -> File”. Enter “File name” as
“[Link]”* and click “Finish”.
6. Replace the contents of “[Link]” as shown next. Click “Ctrl + S” to
save changes and “Ctrl + W” to close editor.
*Geronimo will throw errors if “[Link]” is not present.
Create Enterprise Application Project
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link]
[Link]
version="5">
<description>Geronimo Samples, Bank</description>
<display-name>Bank</display-name>
<module>
<web>
<web-uri>[Link]</web-uri>
<context-root>/Bank</context-root>
</web>
</module>
<module>
<ejb>[Link]</ejb>
</module>
</application>
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Create Geronimo Deployment Plan
1. In “Project Explorer” view expand “Bank” -> “EARContent” -> “META-
INF” and double click* on “[Link]” to open it in an
editor. Click on “Source” tab to switch to edit source.
2. Replace the contents of this file with the contents provided in “geronimo-
[Link]” file of “[Link]”.
You will notice that this deployment plan defines a database pool by name
“BankPool” which was referenced by Persistence Unit in “[Link]”.
Please note that the Form Based Editors for Geronimo Deployment Plans provided
by Geronimo Eclipse Plug-in is currently limited in its functionality and as
such, Geronimo Deployment Plans have to be created manually.
You can refer Aaron Mulder’s book on
“Apache Geronimo Development and Deployment” for detailed information
on creating Geronimo Deployment Plans.
*Geronimo Eclipse Plug-in v2.0 currently has no support for v2.0 of Geronimo deployment plans. Hence
you might face error while opening them. Please use “Open With -> XML Editor” for the time being.
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Deploy and Run the Java EE App
1. Start Geronimo if it is not already started.
2. Go to “Servers” view. Right click on your server and click “Add and
Remove Projects…”.
3. Select “Bank” under “Available projects:” and click “Add >”. Click
“Finish”. The EAR will now be deployed onto server. Wait until server
“State” is shown as “Synchronised” (You might have to switch back to the
“Servers” view to see the server “State”).
4. Open [Link] in a Browser.
5. Enter “Customer Id:” as “12345” and press “View”. Customer Account
Information will now be displayed.
6. Click “Home”. Enter “Customer Id:” as “6789” and press “View”. An error
page will be shown as this Customer doesn’t exist in database.
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Debug the Java EE application
1. In “Project Explorer” view expand “BankWeb” -> “Java Resources: src” ->
“[Link]” and double click on
“[Link]” to open it in an editor.
2. In the left bar of Editor window, double click on some java code (say the first
executable line of doGet() method). This will create a line break point at that code.
3. Go back to “Servers” view, right click on your server and select “Debug”. This will
re-start your server in Debug mode.
4. Open [Link] in a Browser. Enter “Customer Id:” as “6789” and
press “View”.
5. Eclipse window will pop up asking for Perspective Switch to Debug perspective.
Click Yes. Eclipse will now look as shown in next page.
Debug the Java EE application
6. You can now step through our Servlet code, viewing and changing variable values
as you go.
7. Select following line, right click and select “Run to Line”. You will see that code
is run up to that line.
“String customerCode = [Link]("customerCode");
8. Click “Step Over” icon in the “Debug view” to execute the above line
9. In the “Variables” view, select “customerCode” variable and click in the “Value”
column. You will see that the value of “customerCode” can now be changed.
Change the value number from “6789” to “12345”. Click “Enter”
10. Back in the “Debug” view, click the green icon to continue execution.
11. In the browser you will observe that Account Information for “Customer Id:
12345” is displayed.
Agenda
• Hands-on Exercises - 2: Develop a simple Java EE application
– Application Overview & Design
– Create & populate Database Tables using Admin Console.
– Create EJB project
• Create Database Connection Profile
• Create JPA Entities
• Create Stateless Session Bean
– Create Web project
• Create Servlet & JSPs
– Create Enterprise Application Project and add EJB & Web projects into it.
– Create Geronimo Deployment Plan
– Deploy & Run the Java EE application
• Hands-on Exercises - 3: Debug the Java EE application
• Web Service Tools
Eclipse WTP - Web Service tools
• WSDL editor - both a source editor and a graphical editor.
• Web Service Explorer that lets you search and publish to UDDI
registries, and dynamically test WSDL-based Web Services.
• Web Service Wizard that ties together the full development
lifecycle. It lets you deploy Java classes as Web Services, generate
server and client code from WSDL, and generate test clients, as
well as being integrated with the Web Service Explorer for
publishing and discovery.
• Web Service Interoperability (WS-I) Test Tools that lets you
validate WSDL and SOAP for compliance with the WS-I profiles.
• TCP/IP monitor that's very handy for debugging HTTP traffic.
Q&A
Shiva Kumar H.R.
shivahr@[Link] / dev@[Link]
References
• IBM developerWorks article by author Sing Li – “Geronimo! Part 1: The
J2EE 1.4 engine that could”
– [Link]
• Arthur Ryman’s article “Eclipse: The Story of Web Tools Platform 0.7”
at Java Developer's Journal
– [Link]
• Eric J. Bruno’s article “NetBeans 4.1 & Eclipse 3.1” at Dr. Dobb's Portal
– [Link]
• IBM GetStarted with Application Deployment on WebSphere Application
Server Community Edition
– [Link]
• Apache Geronimo v2.0 EJB sample application
– [Link]