Home > Articles > Programming > Java

Development and Deployment for WebLogic and WebSphere

  • Print
  • + Share This
JBuilder's support for multiple application servers makes it among the most versatile IDEs available. This chapter will teach you how to make JBuilder work with WebLogic and WebSphere, noting the particular differences between each application server.
This chapter is from the book

This chapter is from the book

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 deployment—from integrating enterprise systems and databases to delivering services and collaborating over the Internet—the 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 Server—single server.

  1. 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.

  2. 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.

  3. Supply the following properties to the Configuration Wizard:

  4. 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.1Figure 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:

  1. Click Tools, Configure Servers.

  2. Select WebLogic Application Server 6.x+.

  3. Click the Enable server check box.

  4. Enter the following properties for the WebLogic Application Server:

  5. Property

    Value

    Home directory

    c:\bea\weblogic\server

    Main class

    weblogic.Server

    VM parameters

    -ms64m
    -mx64m
    -Djava.library.path=/bea/wlserver6.0/bin
    -Dbea.home=/bea

    -Dweblogic.Domain=mydomain

    -Dweblogic.Name=myserver

    -Djava.security.policy==/bea/wlserver6.0/lib/weblogic.policy
    -Dweblogic.management.discover=false

    -Dweblogic.ProductionModeEnabled=false

    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:

  1. Select File, New, Project tab from the Object Gallery.

  2. Choose Project.

  3. In the Project Wizard - Step 1 of 3, specify the project name and other important properties.

  4. Select Finish.

  5. Choose Project, Project Properties.

  6. Select the Server tab (see Figure 27.2).

  7. Figure 27.2Figure 27.2 Project Properties window for the newly created 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.

  8. Select the WebLogic Application Server 6.x+ in the combo box.

  9. Compile and save your 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:

  1. Create a Web application. Select File, New, Web tab in the Object Gallery.

  2. Select a Web application. Make sure to choose the check box Generate WAR.

  3. Click File, New, Web tab in the Object Gallery.

  4. Select the JavaServer page.

  5. Compile and save the project.

  6. 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:

  1. Double-click on the EJB module you want to use as the container for your new Session Bean.

  2. Right-click on the design window or on the node and select New Session Bean.

  3. Name and configure your Session Bean (see Figure 27.3). Configure the following properties:

  4. Bean name:

    weatherStation

    Interfaces:

    Remote

    Session type:

    Stateless


    Figure 27.3Figure 27.3 Configure your Session Bean by changing the properties through the EJB Designer.

  5. 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):

  6. Method name:

    getCurrentTemp

    Return type:

    int

    Input parameters:

    java.lang.String zipcode

    Interfaces:

    Remote


    Figure 27.4Figure 27.4 Using the context menu to add methods or fields to your Session Bean graphically.

    Figure 27.5Figure 27.5 Configuring your method and assigning the given properties.

  7. 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.

  8. Figure 27.6Figure 27.6 Change the default package for a Session Bean.

  9. Compile and save your project.

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:

  1. 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.

  2. 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

  3. 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.

  4. Define relationships.

  5. 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:

  1. Copy startWebLogic.cmd to startRemoteWeblogic.cmd. This file is located in your user project directory plus your WebLogic domain name—for example, c:\bea\user_projects\dev.

  2. Make the following change to your newly copied startRemoteWeblogic.cmd file:

  3. @rem Call WebLogic Server
    call "c:\bea\weblogic700\server\bin\startRemoteWLS.cmd"
  4. Copy from c:\bea\weblogic700\server\bin the file startWLS.cmd to startRemoteWLS.cmd.

  5. Make the following changes to startRemoteWLS.cmd:

  6. Modification 1—Change 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 2—Change 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
  7. Start the WebLogic Application Server by executing c:\bea\user_projects\ dev\startRemoteWebLogic.

  8. Create a new run configuration. Select Run, Configuration.

  9. Click the New button to create a new configuration.

  10. Click the Debug tab to edit the runtime properties (see Figure 27.7).

  11. Figure 27.1Figure 27.7 Debug runtime configuration for remotely debugging a WebLogic deployment.

  12. Assign a configuration name to the newly created configuration. Check the Enable Remote Debugging check box.

  13. Click the Attach within the Remote Settings panel.

  14. Enter the address as 5555 and change the Build Target to <NONE>.

  15. Assign breakpoints to the remote code.

  16. Select Run, Debug Project. Select the Remote Debug configuration created earlier. This starts your application in debug mode.

  17. Debug your application.

  • + Share This
  • 🔖 Save To Your Account