CPSC 476 - Java Enterprise Application Development: Homework Assignment 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

CPSC 476 – Java Enterprise Application Development

Homework Assignment 2
Due September 14

Your First Cup

Work through the tutorial Your First Cup: An Introduction to the Java EE Platform
(http://download.oracle.com/javaee/5/firstcup/doc/).

While the tutorial specifies NetBeans 5.5, you can use NetBeans 6.9; see Updates and
Tips below.

One section of the tutorial is particularly difficult to follow. When you reach Creating
the gree tin g. js p Page, save yourself some grief and copy the contents of
example\firstcup\firstcup-war\web\greeting.jsp rather modifying the page step-
by-step as described. Pick up the tutorial again at Defining Page Navigation. You may
wish to do the same for response.jsp, but those instructions are a bit easier to follow.

As you work through the tutorial:

1. Which Java EE containers comprise the middle tier of a multi-tiered application?


2. When you have deployed the firstcup-dukes-age Web Service, take a
screenshot showing the NetBeans Output window.
3. Open the Services tab and expand Servers → GlassFish 2.x. Can you find the
Web Service that was deployed? Take a screenshot.
4. Looking at the code for DukesBirthdayBean, where does the information passed
to logger.info() go?
5. Compare DukesBirthdayBean and DukesBDay. Why are there two different
beans? Why is only one an EJB? Which tier does each bean belong to? Do they
run in different containers?
6. Take screenshots of the greeting and response pages.
7. NetBeans catches a mistake in response.jsp. What is it?
8. When you run ant deploy, submit screenshots or transcripts of the output for
both firstcup-dukes-age and firstcup.
9. What happens when you run an asadmin undeploy after having already run ant
undeploy?
10. If NetBeans takes care of deployment for you, why would you want to use Ant or
asadmin?
Updates and Tips
• In Getting the Tutorial Bundle, use firstcup-1.0.2.zip. Unzip into the root
of Drive C: so that a directory called C:\firstcup-1.0.2 is created.
• Instead of Sun Java System Application Server, you will be using GlassFish
v2.x.
• The Server Manager has been renamed to Servers.
• When you open the Servers Dialog in the Lab, you may get a message about
forgetting existing passwords and starting with a fresh keyring. Click Ok, then
reset the Password: field to adminadmin and close the dialog.
• The GlassFish application server should already be installed and registered in the
Lab. Except for resetting the password, you only need to follow the rest of
instructions under Building the Examples with NetBeans if you are installing on
another machine. Note that these instructions are repeated in Coding the
Example Application.
• If you do plan to install on another machine, you can obtain GlassFish from
https://glassfish.dev.java.net/downloads/v2.1.1-final.html.
• When editing files in Building the Examples on the Command-Line Using
Ant, note that the configuration files use UNIX line endings and will not work
with the Windows Notepad. Use TextPad or another text editor.
• In the Lab, set javaee.home to c:/Program Files/NetBeans
6.9/Sun/AppServer.

• In the New Project dialog, the category Web is now Java Web and Enterprise
is now Java EE.
• In the New File dialog, the category Java Classes is now Java.
• The DukesAge class will probably be generated without a default constructor.
• The Projects context menu now says Build or Deploy instead of Build Project or
Deploy Project.
• In Creating the Enterprise Application, there will be no application.xml file
until you Right-click the firstcup module and choose New → Standard
Deployment Descriptor… and click Finish.
• When pasting code, into NetBeans, you may wish to Right-click in the editor
window and select Format to fix the indentation.
• There is no EJB Methods entry in the Right-click popup menu. Instead, you will
see a lightbulb icon in the left margin at the beginning of the
getAgeDifference() method. Left-click the lightbulb and choose Expose
method in remote business interface Dukes Bi r thd ay Be an Re mo te . Note
that the changes described in the next section (Modify
Duk es Bi rt hd ay Re mo te .j ava ) have been made automatically by NetBeans.
• In Setting firstc up -w ar to Support JavaServer Faces Technology, the
servlet URL mapping is now JSF Servlet URL Pattern: on the Categories tab.
There is no Validate XML checkbox.
• Note that the File menu no longer has a Refresh All Files entry. The Projects
pane should be updated automatically.
• When you open faces-config.xml, the XML view is no longer the default.
• Note that the changes described in Adding a Dependency on the Enterprise
Bean Module have been made automatically by NetBeans.
• In Adding An Enterprise Bean Reference, note that the name of the EJB remote
interface is now DukesBirthdayBeanRemote rather than DukesBirthdayRemote.
• Since NetBeans no longer generates default constructors, you will need to add one
to the DukesBDay class. Right-click in the editor window, select Insert Code…
→ Constructor... → Generate.
• In Getting Duke’s Current Age, note that dragging the getDukesAge operation
into the editor no longer works as described. Paste in the code from the tutorial
instead.
• In Configuring the Dukes BD ay Managed Bean, the popup menu is no longer
JavaServer Faces → Add Managed Bean. Instead choose Insert → Managed
Bean… The same applies to adding Add Navigation Rule and Add Navigation
Case in later sections.
• In Preparing the Deployment Descriptor, you will probably find that no
Context Parameters have been defined.
• In Building, Packaging, and Deploying and Running the Example
Application, the “terminal” is a Windows Command Prompt.
• In Building and Packaging first cu p- du ke s- age Using Ant, on Lab
machines type the following to configure the path:

set PATH=C:\Program Files\Java\jdk1.6.0_21\bin;%PATH%;C:\Program Files\NetBeans


6.9\Sun\AppServer\lib\ant\bin

Note that this change applies only in the Command Prompt window where you
typed it. To make the change permanent, you would need to make the change
under the computer’s Advanced system settings.

You might also like