It's time to create the initial descriptor information for Survey2App. While we are accumulating quite a few files, remember that the JSPs, the constants classes, and the RockSurveyRemote home and component classes are copies from Example: The Rock Survey, Take 1; RockSurvey2Bean is an expansion of RockSurveyBean. In this portion, we will create the EAR, add the SurveyNamesBean entity bean, add the revised RockSurvey2Bean session bean, and add the Web component's WAR file.
-
Compile the Java source files in the Survey2 directory, or copy the .class files from the
prod folder.
-
Start J2EE and
deploytool.
-
Ensure that the Cloudscape database is started.
Create new application
-
From the menu, select File, New, Application.
-
Browse to the Survey2 folder.
-
Key Survey2App.ear for the file name.
-
Click New Application.
-
Application Display name is Survey2App by default; click OK.
Create new Enterprise JavaBean component — SurveyNamesBean
-
Ensure that Application Survey2App is selected.
-
From the menu, select File, New, Enterprise Bean — Intro display appears; click Next.
-
Select Create New JAR File In Application.
-
Ensure that Survey2App is selected in the drop-down menu.
-
In JAR Display Name, key Survey2JAR.
-
Click Edit.
-
Select the .class files that comprise the bean. These are:
SurveyNamesBean.class
SurveyNamesKey.class
SurveyNamesLocal.class
SurveyNamesLocalHome.class
-
Click Add; click OK; click Next.
-
Under Bean Type, click Entity.
-
In the Enterprise Bean Class combo box, select the bean implementation: SurveyNamesBean.
-
In Enterprise Bean Name, accept SurveyNamesBean.
-
Select the corresponding interfaces in the combo boxes:
For Local Home Interface, select: SurveyNamesLocalHome.
For Local Interface, select: SurveyNamesLocal.
-
Click Next.
-
Ensure that Bean-Managed Persistence is selected under Persistence Management.
-
Key SurveyNamesKey in the Primary Key Class textfield. Click Finish.
-
Survey2JAR and SurveyNamesBean now appear under Survey2App.
-
Click the Resource Refs tab; click Add.
-
Under Coded Name, enter "jdbc/gsejbDB". Leave Type as "javax.sql.DataSource", Authentication
as "Container", and Sharable checked.
-
Select Survey2JAR, then click the JNDI Names tab.
-
Under EJBs, key ejb/SurveyNamesBean next to SurveyNamesBean.
-
Under References, enter "jdbc/gsejbDB".
Create new Enterprise JavaBean component — RockSurvey2Bean
-
Ensure that Application Survey2App is selected.
-
From the menu, select File, New, Enterprise Bean — Intro display appears; click Next.
-
Select Add to Existing JAR File.
-
Select Survey2JAR in the drop-down menu.
-
Click Edit.
-
Select the .class files that comprise the bean. These are:
RockSurvey2Bean.class
RockSurveyConstants.class
RockSurveyData.class
RockSurveyRemote.class
RockSurveyRemoteHome.class
SurveyConstants.class
-
Click Add; click OK; click Next.
-
Under Bean Type, click Session and Stateful.
-
In the Enterprise Bean Class combo box, select the bean implementation: RockSurvey2Bean.
-
In Enterprise Bean Name, accept RockSurvey2Bean.
-
Select the corresponding interfaces in the combo boxes:
For Remote Home Interface, select: RockSurveyRemoteHome.
For Remote Interface, select: RockSurveyRemote.
-
Click Next; click Finish.
-
RockSurvey2Bean now appears under Survey2JAR. Select the EJB Refs tab, click Add.
-
When the bean invokes the lookup method, it refers to the home of an enterprise bean like this:
Object objRef = ic.lookup("java:comp/env/ejb/SurveyNamesBean");
So, in the Coded Name column, enter ejb/SurveyNamesBean.
-
Select Entity for Type and Local for Interfaces.
-
For Home Interface, enter SurveyNamesLocalHome.
-
In the Local/Remote Interface column, enter SurveyNamesLocal.
-
At the bottom, select
ejb-jar-ic.jar#SurveyNamesBean from the Enterprise Bean Name drop-down menu.
-
Select Survey2JAR, then click the JNDI Names tab.
-
Under EJBs, key ejb/RockSurvey2Bean next to RockSurvey2Bean.
Create new Web component
- Ensure that Application Survey2App is selected.
-
From the menu, select File, New, Web Component — Intro display appears; click Next.
-
Select Create New WAR File In Application.
-
Ensure that Survey2App is selected in the drop-down menu.
-
In WAR Display Name, key Survey2WAR.
-
Click Edit.
-
Select the files needed for the Web component. These are:
The images directory
index.jsp
RockSurvey.jsp
RockSurveyExit.jsp
SurveyWelcome.jsp
-
Click Add; click OK; click Next.
-
Select JSP for the type of Web component, then click Next.
-
In the JSP filename combo box, select index.jsp.
-
In Web Component Name, allow the default — index.
-
Click Next. There are no Initialization Parameters. Click Next.
-
Under Component Aliases, click Add, enter "/index" (without quotes).
-
Click Next; click Finish.
-
Survey2WAR now appears under Survey2App.
-
Select Survey2WAR, then select the EJB Refs tab and click Add.
-
When the Web client invokes the lookup method, it refers to the home of an enterprise bean like this:
Object objRef = ic.lookup("java:comp/env/ejb/RockSurveyBean");
So, in the Coded Name column, enter ejb/RockSurveyBean.
-
Accept Session for Type and Remote for Interface.
-
For Home Interface, enter RockSurveyRemoteHome.
-
In the Local/Remote Interface column, enter RockSurveyRemote.
-
At the bottom, select
ejb-jar-ic.jar#RockSurvey2Bean from the Enterprise Bean Name drop-down menu. Then click the JNDI Name button and select ejb/RockSurvey2Bean from the drop-down menu.
-
Now select Survey2App and click on the JNDI Names tab.
-
Verify that all JNDI Name columns have the proper entries.
The code we have so far only handles writing data to the SurveyNames table. The bean to handle the survey data table will be added after the CMP discussion, so we will wait until Final Deployment of the Rock Survey, Take 2 for the actual, final deployment of Survey2App.