- Using WebLogic with JBuilder
- Using IBM WebSphere with JBuilder
- Summary
Using IBM WebSphere with JBuilder
The IBM WebSphere software platform for e-business is a comprehensive set of award-winning, integrated e-business solutions. It's a software platform based on industry standardsmaking it flexible and pluggable, which can allow you to adapt on-the-fly as markets shift and business goals change. Building on this robust platform, you can integrate diverse IT environments to maximize current investments, deliver core business applications to the Web, grow these applications to meet changing needs and increasing demand, and create a differentiated e-business that sets your business apart from the competition. As we look at the integration between JBuilder, we will look at the following key elements for using the best-of-breed IDE:
Installing WebSphere
Configuring JBuilder for WebSphere
Developing servlets and JSPs
Developing EJBs
Deploying your application components
Debugging
Installing WebSphere
IBMWebSphere is delivered in three different versions: Standard, Advanced, and Enterprise. When developing with JBuilder for the WebSphere platform, working with the Advanced Single Server Edition installed locally on your development workstation is advantageous.
NOTE
For consistency throughout this chapter, we suggest you install IBM WebSphere within c:\WebSphere.
Configuring JBuilder with WebSphere
JBuilder supports a wide variety of different application servers, WebSphere being one of them. To have JBuilder properly communicate with these environments, you must configure JBuilder to recognize them. When an application server environment is selected, JBuilder then configures the features, code generators and wizards, command-line utilities, class paths, and deployment and runtime options for the vendor's specific implementation requirements. We will use this application server for building our application; however, the same principles apply regardless of the application server brand or versions selected. To access JBuilder's configuration of application servers, enter the editor by choosing Tools, Configure Servers from the menu (see Figure 27.8) and enable the application servers you want to use within JBuilder. This is not a one-time setup for each developer's login, but you can change these parameters by reentering the editor anytime.
To enable the desired application server, select it in the list on the left and click the Enable server check box for that application server configuration. You now have full access to the features available within the given application server. For example, if you choose an application server that does not support EJB 2.0 Entity Beans, it will not allow you to build 2.0 Entity Beans within your application.
Figure 27.8 Application server setup within the JBuilder environment for WebSphere integration.WebSphere 4.0 is not specifically supported within the JBuilder environment but can easily be configured to work. The following steps set up WebSphere 4.0 within the JBuilder environment:
Click Tools, Configure Servers.
Select WebSphere Application Single Server 4.0.
Click the Enable Server check box.
Enter the following properties for the WebSphere Application Server:
Property |
Value |
Home directory |
c:/WebSphere/AppServer |
Main class |
com.ibm.ws.bootstrap.WSLauncher |
VM parameters |
--Xms17m -Xmx128m -Xminf0.15 -Xmaxf0.25 |
Server parameters |
-com.ibm.ejs.sm.server.AdminServer -bootFile /WebSphere/AppServer/bin/admin.config -nodeRestart |
Working directory |
c:/WebSphere/AppServer/bin |
Using Servlets and JSPs with WebSphere
When using JBuilder, the IDE isolates the differences between the application server containers within its wizards. For example, the process for creating JSPs and servlets is exactly the same as that of BES, with one exception. This exception is to specify which container will supply the necessary services for implementation. The following steps are necessary to create a BEA JSP and servlet project:
Select File, New, Project tab from the Object Gallery.
Choose Project.
In the Project WizardStep 1 of 3, specify the project name and other important properties.
Select Finish.
Choose Project, Project Properties.
Select the Server tab.
Select the WebSphere Application Advanced Single Server 4.0 in the combo box.
Compile and save your project.
NOTE
JBuilder not only allows for development and deployment to multiple application servers, but also allows for a mixing of service providers across the same project.
All other processes for creating JSPs and servlets are exactly the same.
The following process is used to create a Web application using WebSphere Application Server:
Create a Web application by selecting File, New, Web tab in the Object Gallery.
Select a Web application. Make sure to choose the check box Generate WAR.
Click File, New, Web tab in the Object Gallery.
Select the JavaServer page.
Compile and save the project.
Right-click on the JSP and select Web Run using <name>.jsp.
Developing EJBs with WebSphere
Each Enterprise Bean you create must belong to a JBuilder EJB module. The restriction with developing the EJB module for IBM WebSphere is that you will not be able to use EJB 2.0. An EJB module is a logical grouping of one or more Beans that will be deployed in a single JAR file, using IBM WebSphere only using EJB 1.x Beans.
Developing Session Beans
To create an EJB 1.x module and build some Session Beans within the module, follow these steps:
-
Create an EJB module within a project. The restriction placed on your project by IBM WebSphere requires the EJB module to be version 1.x (see Figure 27.9).
Figure
27.9 Building an EJB module with JBuilder for IBM WebSphere.
-
To create a Session Bean, select File, New. Select the Enterprise tab and choose Enterprise JavaBean 1.x (see Figure 27.10).
-
Click Next, which assigns the existing EJB module (see Figure 27.11).
-
Assign the properties shown in Figure 27.12 to your Session Bean and click Next.
-
View the package names and JNDI settings for your Session Bean and click Finish (see Figure 27.13).
-
Add your business logic using the source created by the wizard.
Figure 27.10 Select the Enterprise JavaBean 1.x from the Object Gallery.
Figure 27.11 Building a Session Bean with Enterprise JavaBean 1.x; Select EJB Module (Step 1 of 3).
Figure 27.12 Building a Session Bean with Enterprise JavaBean 1.x; Create a New EJB Component (Step 2 of 3).
Figure 27.13 Building a Session Bean with Enterprise JavaBean 1.x; assign JNDI names and other properties (Step 3 of 3).
Developing Entity Beans with WebSphere
Using BEA WebLogic or Borland Enterprise Server, you used the EJB 2.0 Designer for implementing Entity Beans. As noted earlier, IBM WebSphere supports only EJB 1.x, thus we must use the 1.x Entity Bean Modeler. The following process builds Entity Beans using IBM WebSphere:
-
Select File, New and select the Enterprise tab within the Object Gallery.
-
Select the EJB 1.x Entity Bean Modeler.
-
Leave the default EJB module. The name should be WebSphere_Bean (see Figure 27.14). Click Next.
Figure
27.14 EJB 1.x Entity Bean Modeler (Step 1 of 7); Select EJB Module.
-
Supply the connection information to the data source (see Figure 27.15). The following parameters use the JDataStore employee database:
-
This step allows you to select the tables from the database. The left panel shows the list of available tables for the database you selected in the previous window; the right panel shows the selected tables. The only table we will provide as an Entity Bean is Employee (see Figure 27.16).
Figure
27.16 EJB 1.x Entity Bean Modeler (Step 3 of 7); select tables to make an
Entity Bean.
-
Assign the columns to make available within the Entity Bean (see Figure 27.17). Make all the columns available to the Entity Bean.
-
Specify the names and types of each property within the Entity Beans (see Figure 27.18). Leave the settings with the default values.
Figure
27.18 EJB 1.x Entity Bean Modeler (Step 5 of 7); supply the column types
and names.
-
Change the default package name to com.sams.websphere (see Figure 27.19). Although we are going to leave the remaining properties as the defaults, you can also change the names of any of the interfaces or change the JNDI names.
Figure
27.19 EJB 1.x Entity Bean Modeler (Step 6 of 7); supply the interface and
package names.
-
Assign the properties for the Entity Bean. These properties control the Bean's behavior when deployed. Leave all the properties with the defaults, except check Generate findAll() method in the home interface (see Figure 27.20).
Property |
Value |
Drive |
com.borland.datastore.jdbc.DataStoreDriver |
URL |
-jdbc:borland:dslocal:C:\Development\JBuilder7\samples\ JDataStore\datastores\employee.jds |
Username |
Sample |
JNDI name |
EmployeeDataSource |
Figure 27.15 EJB 1.x Entity Bean Modeler (Step 2 of 7); supply JDBC connection properties.
Figure 27.17 EJB 1.x Entity Bean Modeler (Step 4 of 7); assign available columns to the Entity Bean.
Figure 27.20 EJB 1.x Entity Bean Modeler (Step 7 of 7); change the generation options for the deployed Bean.
Deploying Your Application
To run the Session Bean, open a project and then create an EAR file, deploy the EAR file, and restart WebSphere. To accomplish this task, JBuilder provides a number of tasks important in the process. At the time of project make, JBuilder runs the WebSphere compiler to generate the deployment descriptors and container-generated files. For the deployment of your JAR or EAR, right-click on your archive and select Deploy.
Debugging a WebSphere Application
WebLogic can be started remotely by providing the options debugEnable-jdwpPort <Port #> to the startServer command. The following process enables you to debug your application:
Start an MS-DOS window.
Type C:\WebSphere\AppServer\bin\startServer debugEnable jdwpPort 5555. This starts your server in debug mode.
Click Run, Configurations and select the Run tab.
Click New and select the Debug tab.
Enter the configuration name as Remote Debug WebSphere. Check Enable Remote Debugging.
Click Attach in the Remote Settings panel. Enter the address of the debug portfor example, port 5555.
Set your breakpoints and debug your application.
NOTE
The address specified here must be the same as the port number specified in the server as debug options. JBuilder opens a socket connection to the WebSphere server and attaches using the port number 5555.