Development and Deployment for WebLogic and WebSphere
- Using WebLogic with JBuilder
- Using IBM WebSphere with JBuilder
- Summary
In This Chapter
- Using WebLogic with JBuilder
- Using IBM WebSphere with JBuilder
JBuilder's support for multiple application servers makes this the most versatile IDE on the market. The support includes not only the writing of code but deploying, debugging, and wizards also. As we look at the difference between WebLogic and WebSphere, you will notice JBuilder's capability to mask the differences from application server to application server. The following processes are important to examine for each application server:
-
Installing the application server
-
Developing a JSP and/or servlet
-
Creating EJBs
-
Deploying your application
-
Remote debugging your application
Using WebLogic with JBuilder
BEA WebLogic Application Server is a full-featured, standards-based application server providing the foundation on which an enterprise can build its applications. For all the crucial tasks of application development and deploymentfrom integrating enterprise systems and databases to delivering services and collaborating over the Internetthe starting place is BEA WebLogic Server. With its comprehensive set of features, compliance with open standards, multitiered architecture, and support for component-based development, WebLogic Application Server is the choice of Internet-savvy businesses to develop and deploy best-of-breed applications. As we look at the integration between WebLogic and JBuilder, we will look at the following key elements for using the best-of-breed IDE:
Installing WebLogic
Configuring JBuilder for WebLogic
Developing servlets and JSPs
Developing EJBs
Deploying your application components
Debugging
Installing WebLogic Application Server
To create and install WebLogic Application Server, you typically follow the installation directions provided by BEA. The process for creating a server varies from platform to platform, but this chapter shows specifically how to configure and set up a single server within the Windows environment. To develop and debug your WebLogic application, it is most advantageous to install the server locally with your installation of JBuilder. The following steps are required to set up a WebLogic Application Serversingle server.
Install the WebLogic Application Server into the C:\BEA directory. Use the supplied setup either downloaded from the BEA Web site or using the BEA distribution CD.
Create and configure a server using the Configuration Wizard. This wizard is accessed by clicking on Start, All Programs, BEA WebLogic Platform 7.0, Configuration Wizard.
Supply the following properties to the Configuration Wizard:
Property |
Value |
Domain name |
dev |
Server type |
Single Server |
Domain location |
C:\bea\user_projects\ |
NOTE
From this point forward, the domain location will actually be the domain location plus the name of the domain. For example, in this instance the directory location is actually c:\bea\user_projects\dev.
Configuring JBuilder with WebLogic
JBuilder supports a wide variety of different application servers, WebLogic 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, classpaths, and deployment and runtime options for the vendor's specific implementation requirements. To access JBuilder's configuration of application servers, you must enter the editor by choosing Tools, Configure Servers from the menu (see Figure 27.1) 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.
Figure 27.1 Application server setup within the JBuilder environment for WebLogic integration.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.
WebLogic 7.0 is not specifically supported within the JBuilder environment but can easily be configured to work. The following steps set up WebLogic 7.0 within the JBuilder environment:
Click Tools, Configure Servers.
Select WebLogic Application Server 6.x+.
Click the Enable server check box.
Enter the following properties for the WebLogic Application Server:
Property |
Value |
Home directory |
c:\bea\weblogic\server |
Main class |
weblogic.Server |
VM parameters |
-ms64m |
Working directory |
c:\bea\user_projects\dev |
Using Servlets and JSPs with WebLogic
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 Wizard - Step 1 of 3, specify the project name and other important properties.
-
Select Finish.
-
Choose Project, Project Properties.
-
Select the Server tab (see Figure 27.2).
Figure
27.2 Project Properties window for the newly created project.
-
Select the WebLogic Application Server 6.x+ 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 WebLogic Application Server:
Create a Web application. Select 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.
Working with EJBs
Creating an EJB-based solution implemented within WebLogic is similar to creating a JSP. The preparatory tasks of specifying the application server are exactly the same. The only difference happens if the version of WebLogic supports varying forms of EJB specification. For example, when using versions of WebLogic prior to version 6.5, you will have a limited feature set available within JBuilder. CMP 2.0 is one such feature that is not available.
Creating a Session Bean
Using the JBuilder EJB Designer, we are going to create a Session Bean that uses the interface implemented in our earlier client application. To build this Session Bean, we will perform a set of steps within JBuilder's IDE:
-
Double-click on the EJB module you want to use as the container for your new Session Bean.
-
Right-click on the design window or on the node and select New Session Bean.
-
Name and configure your Session Bean (see Figure 27.3). Configure the following properties:
-
Right-click on the new Session Bean and add a method. This process is similar to adding a new field (see Figure 27.4). The method you want to add is the following (see Figure 27.5):
-
Assign the desired names to the generated code for the Bean implementation, as shown in Figure 27.6. For example, change the default package of the Session Beans to com.sams.weatherstation.session. This is accomplished by selecting the classes and packages button on the properties for the entire Bean. If you do not see this button on the properties pop-up panel of the Bean, reselect the title of the Bean.
Figure
27.6 Change the default package for a Session Bean.
-
Compile and save your project.
Bean name: |
weatherStation |
Interfaces: |
Remote |
Session type: |
Stateless |
Figure 27.3 Configure your Session Bean by changing the properties through the EJB Designer.
Method name: |
getCurrentTemp |
Return type: |
int |
Input parameters: |
java.lang.String zipcode |
Interfaces: |
Remote |
Figure 27.4 Using the context menu to add methods or fields to your Session Bean graphically.
Figure 27.5 Configuring your method and assigning the given properties.
Creating an Entity Bean
Just like Session Beans, the Entity Bean usage does not change dramatically more than the BES development and deployment. The following steps create an Entity Bean using the WebLogic environment:
-
Import a schema from the data source in the EJB module containing your Session Beans. This is accomplished by right-clicking on the data source node when you are in the EJB Designer and selecting Import Schema from Datasource.
-
Set the following database parameters:
-
Driver: com.borland.datastore.jdbc.DataStoreDriver
-
URL: jdbc:borland:dslocal:C:\JBDG\db\ChalkTalk.jds
-
Username: leave blank
-
Password: leave blank
-
Right-click on each table and create a CMP 2.0 Entity Bean for each table. For example, right-click on the table room and create a CMP 2.0 Bean.
-
Define relationships.
-
Compile and save your project.
Deploying Your Application
JBuilder insulates you from the details of the implementation that are WebLogic specific. For example, the deployment descriptor has some WebLogic-specific information contained within many of its components (see Listing 27.1).
Listing 27.1 WebLogic Deployment Descriptor for a Sample Project (weblogic-ejb-jar.xml Located within the Deployment JAR)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc. //DTD WebLogic 7.0.0 EJB//EN' 'http://www.bea.com/servers/wls700/dtd/weblogic-ejb-jar.dtd'> <weblogic-ejb-jar> <weblogic-enterprise-bean> <ejb-name>Cart</ejb-name> <reference-descriptor> <ejb-local-reference-description> <ejb-ref-name>ejb/Orderitem</ejb-ref-name> <jndi-name>Orderitem</jndi-name> </ejb-local-reference-description> <ejb-local-reference-description> <ejb-ref-name>ejb/ShoppingCart</ejb-ref-name> <jndi-name>ShoppingCart</jndi-name> </ejb-local-reference-description> <ejb-local-reference-description> <ejb-ref-name>ejb/ServerDataModule</ejb-ref-name> <jndi-name>ServerDataModule</jndi-name> </ejb-local-reference-description> <ejb-local-reference-description> <ejb-ref-name>ejb/User</ejb-ref-name> <jndi-name>User</jndi-name> </ejb-local-reference-description> </reference-descriptor> <jndi-name>Cart</jndi-name> ... </weblogic-enterprise-bean> <weblogic-enterprise-bean> <ejb-name>Sequence</ejb-name> <entity-descriptor> <persistence> <persistence-use> <type-identifier>WebLogic_CMP_RDBMS</type-identifier> <type-version>6.0</type-version> <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml </type-storage> </persistence-use> </persistence> </entity-descriptor> <local-jndi-name>Sequence</local-jndi-name> </weblogic-enterprise-bean> </weblogic-ejb-jar>
This file contains all the WebLogic-specific configurations required for the deployment of your application.
Remote Debugging
JBuilder contains the facilities to remotely debug an application running within another JVM process. To remotely debug this application deployed on the application server, specifically WebLogic Server, you must start your server in debug mode. The following process is required to create the hooks necessary for remote debugging within WebLogic:
-
Copy startWebLogic.cmd to startRemoteWeblogic.cmd. This file is located in your user project directory plus your WebLogic domain namefor example, c:\bea\user_projects\dev.
-
Make the following change to your newly copied startRemoteWeblogic.cmd file:
-
Copy from c:\bea\weblogic700\server\bin the file startWLS.cmd to startRemoteWLS.cmd.
-
Make the following changes to startRemoteWLS.cmd:
-
Start the WebLogic Application Server by executing c:\bea\user_projects\ dev\startRemoteWebLogic.
-
Create a new run configuration. Select Run, Configuration.
-
Click the New button to create a new configuration.
-
Click the Debug tab to edit the runtime properties (see Figure 27.7).
Figure
27.7 Debug runtime configuration for remotely debugging a WebLogic deployment.
-
Assign a configuration name to the newly created configuration. Check the Enable Remote Debugging check box.
-
Click the Attach within the Remote Settings panel.
-
Enter the address as 5555 and change the Build Target to <NONE>.
-
Assign breakpoints to the remote code.
-
Select Run, Debug Project. Select the Remote Debug configuration created earlier. This starts your application in debug mode.
-
Debug your application.
@rem Call WebLogic Server call "c:\bea\weblogic700\server\bin\startRemoteWLS.cmd"
Modification 1Change the classpath.
set CLASSPATH=%JAVA_HOME%\lib\tools.jar; c:\borland\jbuilder7\lib\jaxrpc.jar; c:\borland\jbuilder7\lib\jds.jar; c:\borland\jbuilder7\lib\jdsremote.jar; c:\borland\jbuilder7\lib\jdsserver.jar; %WL_HOME%\server\lib\weblogic_sp.jar; %WL_HOME%\server\lib\weblogic.jar;%CLASSPATH%
Modification 2Change command switches for starting WebLogic Server.
@rem Start Server @echo off if "%ADMIN_URL%" == "" goto runAdmin @echo on "%JAVA_HOME%\bin\java" -classic %MEM_ARGS% -Xdebug Xnoagent Djava.compiler=NONE Xrunjdwp:transport=dt_socket,server=y,address=5555,suspend=n %JAVA_OPTIONS% classpath "%CLASSPATH%" -Dweblogic.Name=%SERVER_NAME% Dbea.home="C:\bea" -Dweblogic.management.username=%WLS_USER% Dweblogic.management.password=%WLS_PW% Dweblogic.management.server=%ADMIN_URL% Dweblogic.ProductionModeEnabled=%STARTMODE% Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" Daxis.enableListQuery=true weblogic.Server goto finish :runAdmin @echo on "%JAVA_HOME%\bin\java" -classic %MEM_ARGS% -Xdebug -Xnoagent Djava.compiler=NONE Xrunjdwp:transport=dt_socket,server=y,address=5555,suspend=n %JAVA_OPTIONS% classpath "%CLASSPATH%" -Dweblogic.Name=%SERVER_NAME% Dbea.home="C:\bea" -Dweblogic.management.username=%WLS_USER% Dweblogic.management.password=%WLS_PW% Dweblogic.ProductionModeEnabled=%STARTMODE% Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" Daxis.enableListQuery=true weblogic.Server :finish