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 stepby-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?
There is no EJB Methods entry in the Right-click popup menu. If you do plan to install on another machine.0. you only need to follow the rest of instructions under Building the Examples with NetBeans if you are installing on another machine. you will be using GlassFish v2. then reset the Password: field to adminadmin and close the dialog.9/Sun/AppServer.java.
• • • • • •
. there will be no application. In the New File dialog. use firstcup-1. the category Java Classes is now Java.1-final. you may get a message about forgetting existing passwords and starting with a fresh keyring. the category Web is now Java Web and Enterprise is now Java EE. Except for resetting the password.2. When you open the Servers Dialog in the Lab. Click Ok. note that the configuration files use UNIX line endings and will not work with the Windows Notepad.home to c:/Program Files/NetBeans 6.zip.html.j ava ) have been made automatically by NetBeans.Updates and Tips
• • • • In Getting the Tutorial Bundle. you may wish to Right-click in the editor window and select Format to fix the indentation. The Server Manager has been renamed to Servers. Note that the changes described in the next section (Modify Duk es Bi rt hd ay Re mo te . The GlassFish application server should already be installed and registered in the Lab. you can obtain GlassFish from https://glassfish. In Creating the Enterprise Application. Instead of Sun Java System Application Server. When editing files in Building the Examples on the Command-Line Using Ant.x. into NetBeans. Instead.net/downloads/v2. In the New Project dialog. Unzip into the root of Drive C: so that a directory called C:\firstcup-1. The Projects context menu now says Build or Deploy instead of Build Project or Deploy Project.1. The DukesAge class will probably be generated without a default constructor. Note that these instructions are repeated in Coding the Example Application. In the Lab. When pasting code. Left-click the lightbulb and choose Expose method in remote business interface Dukes Bi r thd ay Be an Re mo te . set javaee.xml file until you Right-click the firstcup module and choose New → Standard Deployment Descriptor… and click Finish. Use TextPad or another text editor. you will see a lightbulb icon in the left margin at the beginning of the getAgeDifference() method.2 is created.0.dev.
%PATH%. In Getting Duke’s Current Age. the XML view is no longer the default. Packaging.•
In Setting firstc up -w ar to Support JavaServer Faces Technology. you would need to make the change under the computer’s Advanced system settings. select Insert Code… → Constructor. The Projects pane should be updated automatically. the popup menu is no longer JavaServer Faces → Add Managed Bean. Since NetBeans no longer generates default constructors. In Building and Packaging first cu p. In Building. on Lab machines type the following to configure the path:
set PATH=C:\Program Files\Java\jdk1. → Generate. Note that the File menu no longer has a Refresh All Files entry..xml.C:\Program Files\NetBeans 6.. note that dragging the getDukesAge operation into the editor no longer works as described. There is no Validate XML checkbox. In Preparing the Deployment Descriptor.0_21\bin. Note that the changes described in Adding a Dependency on the Enterprise Bean Module have been made automatically by NetBeans.9\Sun\AppServer\lib\ant\bin
• • • • •
• • •
Note that this change applies only in the Command Prompt window where you typed it. note that the name of the EJB remote interface is now DukesBirthdayBeanRemote rather than DukesBirthdayRemote.age Using Ant. To make the change permanent. the “terminal” is a Windows Command Prompt.6. Paste in the code from the tutorial instead. the servlet URL mapping is now JSF Servlet URL Pattern: on the Categories tab. In Configuring the Dukes BD ay Managed Bean. Instead choose Insert → Managed Bean… The same applies to adding Add Navigation Rule and Add Navigation Case in later sections.
. you will probably find that no Context Parameters have been defined. When you open faces-config. Right-click in the editor window. you will need to add one to the DukesBDay class.du ke s. and Deploying and Running the Example Application. In Adding An Enterprise Bean Reference.