Pramati Technologies

Working with WebLogic Server

This chapter is for developers who are familiar with WebLogic Server 6.1 and WebLogic 7.0, and would like to deploy their applications using BEA WebLogic as their production environment.

Studio provides tight integration with WebLogic Server 6.1 and WebLogic 7.0. It automatically creates the required deployment descriptors while the application is being developed, and keeps the application in a "ready-to-deploy" state. Studio provides all the support required for deploying applications both on local and remote servers. Some of the operations that are supported are:

This chapter discusses how to develop EJB 1.1 and EJB 2.0 applications in Studio and deploy them on WebLogic.

Configuring WebLogic Deployer

To develop applications in Studio and test-deploy them on different versions of WebLogic server, the WebLogic Deployer needs to be configured in Studio. To do this, click on Tools > Configure from the main menu. In the Tools Configure dialog that comes up, check against the option - WebLogic Deployer, and close the dialog.

After closing the Tools Configure dialog, multiple instances of the WebLogic server can be created in Studio, which is typically one development server on the development machine and a single central production server on the remote machine.

Note: Each configured Server instance has its own tab in the Output Panel.

Creating WebLogic Server Instances

To create an instance for WebLogic Server, click on Tools > Server Configuration from the main menu. In the Server Configuration dialog that comes up, click on the New button to create a new instance of the server. In the Add New Server dialog that pops up, enter the following information:

Server Name Enter the name of the server instance that is to be created in the dialog

Server Type Select the type of the server from the list in the combo box. To create a WebLogic server instance, select from either of the following three options depending on the version available with you:

Pressing OK creates an instance of the server and displays the Server Config panel, where WebLogic properties are to be configured:

Server Name The Server name is automatically selected as the name entered in the Add New Server dialog. To select another server instance that is to be configured, choose from the list in the combo box

Server Type The Server type is displayed as the type selected in the Add New Server dialog.

IP Address This is the IP address of the machine on which WebLogic Server is installed and where the application will be deployed. This is by default, 127.0.0.1

HTTP Port Enter the HTTP Port number on the local machine that WebLogic Server uses to listen for data. This is by default selected as 7001

Install Dir This is the directory on the local machine, where WebLogic Server has been installed. For example: c:\bea\wlserver6.1.

User Name Enter the user name required to connect to the WebLogic Server. For WebLogic 6.1, and the SP1 and SP2 releases of this version, the user name is system, by default.

Password Enter the password for WebLogic Server in this field.

Server Classpath Enter the server classpath used to start the server in this field. This field also allows additional entries that may be needed for custom/third-party JARs or database drivers to be added. The file weblogic.jar must be there in the server classpath.

EXAMPLE

c:\Pramati Studio 3.0\server\lib\tp\cloudscape.jar

All the JARs of the configured drivers are always added to the server's classpath.

JVM options Enter or browse for the JVM options in this field, which are used to start the virtual machine running WebLogic server. Refer the WebLogic documents for all the available options. If the user specifies the default parameters explicitly, then those options are given the preference over the default options.

BEA Home Browse for and select the appropriate BEA Home directory in this field.

Domain Directory Browse for and select the path of where the domain is located, for WebLogic Server 7.0. This field is disabled for all other versions supported in Studio.

Domain Name The administrative domain name of the running server or the server to be started is displayed in this field. The default is mydomain. This field is disabled when the server type is WebLogic 7.0 and selecting the domain directory in the previous field changes it appropriately, if needed.

A domain is a unit of administration for a WebLogic Server installation. A WebLogic domain may consist of one or more WebLogic Servers.

Target Server Name Enter the name of the server on which the application is to be deployed. For example: myserver.

The name provided in the field Name, is different from the name provided in the field, Target Server Name. The Server Name is a unique name used to identify a server instance, whereas the Target Server Name is the name of the WebLogic admin server. Example: myserver.

Mode Select the Run mode of the server mode as either development or production. The mode is used for deploying applications. If the server is running on a local machine in the development mode, then the archive to be deployed is stored in the application directory of the domain, and the server automatically deploys it. The mode is selected as development mode, by default.

If the server is running in production mode, then the application is deployed as normal archives. For developing applications, which require frequent deployment, undeployment and redeployment, it is recommended that development mode be used.

JMS Server Name Enter the name of the JMS Server only when the JMS Server is to be used. By default the JMS server is not configured on WebLogic Server. To use the JMS Server from Studio, the JMS server has to be created and configured.

Use External JMS Server Check this option to use an external JMS Server with the WebLogic Server instance. Checking this option enables the Initial Context Factory and Provider URL fields.

If you are using the default weblogic JMS server, then Initial Context factory and Provider URL need not be mentioned.

Use the OK button to add the instance of the WebLogic Server. To delete a server instance, select the required server from the field, Server Name and use the Delete button.

Configuring WebLogic embedded JMS Server

Follow the given steps to configure the embedded JMS Server of Console

from Studio:

  1. Use the WebLogic Web Console to create the JMS server OR Add the following tag in the file, config.xml of the configured domain. The file will typically be stored in the configured domain directory.

EXAMPLE

wlserver6.1\config\mydomain\config.xml

<JMSServer Name="myJMSServer" Store="myJDBCStore" Targets="myserver">

</JMSServer>

<JMSJDBCStore ConnectionPool="jmsconpool" Name="myJDBCStore"/>

  1. Give any appropriate name to the JMS server.
  2. JMS server uses a store to persist the messages. The store can be a file store or a database. Typically, the database store is preferred for storing the messages. The tag, JMSJDBCStore in the code above is the storage for JMS server. This store uses a Connection Pool, which should be stored in the Server. If the connection pool does not exist, then the user needs to create one.

EXAMPLE OF A CONNECTION

<JDBCConnectionPool CapacityIncrement=5"

DriverName="oracle.jdbc.driver.OracleDriver" InitialCapacity="5"

MaxCapacity="30" Name="jmsconpool" Password="tiger"

Properties="user=scott" Targets="myserver" URL="jdbc:oracle:thin:@db1:1521:db1"/>

For more details, read the WebLogic Server documentation.

Starting & Stopping Server

After creating the WebLogic server instance in Studio, close the Server Configuration panel, and select the instance from the Server Box in the Status bar. Selecting the WebLogic server instance here makes it the current server, and all server specific operations for the active Desk is performed on the current server.

The WebLogic server can be started/stopped in a similar way as any other server in Studio. Use Tools > Start Server to start the Server. To stop a server, use Tools > Stop Server from the main menu. The Server can also be started/stopped using the signal box.

Remote server cannot be started/stopped from Studio. All other operations can be performed.

Controlling Output Messages

The type of output message can be controlled by specifying the property

-Dweblogic.StdoutSeverityLevel in the VM Option field while configuring the server instance. The values may be given as one of the following: 64 (INFO), 32 (WARNING), 16 (ERROR), 8 (NOTICE), 4 (CRITICAL), 2 (ALERT), 1 (EMERGENCY). The default value used is 16. To get the complete output in Output Panel, provide 64 as the value of the above-mentioned property.

EXAMPLE

-Dweblogic.StdoutSeverityLevel=64

Deploying on WebLogic

Applications can be deployed on WebLogic as normal archived JARs, WARs and EARs, or directly as Modules. Right Clicking on the Desk > Deploy as .ear always deploys the application on the current WebLogic server. Similarly right clicking on the module > Deploy always deploys the module on the current WebLogic server.

The WebLogic server runs in two modes - development and production. When the configured server is local and running in the development mode, the applications are hot-deployed. Hot deploying of applications provides the user the facility of not having to re-deploy the application each time the server is started. In hot-deployment the JAR, WAR, EAR and EJB modules are deployed by storing the archives in the applications directory of the configured server. The server then polls and automatically deploys/redeploys the application, each time it is started.

If the server is remote or is running in the production mode, all modules are deployed as archives.

Deploying the Web Module on a local server deploys the Web Module directory. Any changes made in the files under this module get reflected automatically, and the module need not be re-deployed.

Performing a Lookup operation from the Web Module should be done using references. If the Web Module requires any supporting classes, they must be stored inside a JAR under web-inf\lib.

Studio picks up the interface classes used by ejb-references after it has been set in the Properties panel. To do this, right click on the Web Module and select Properties.

In the panel that comes up, select the Deploy tab and check the option, Auto Include EJB Reference Classes. This automatically picks up the remote or local interfaces and other classes used in the method signature of these interfaces, and puts them in supportingClasses.jar under the directory, web-inf\lib.

Using direct Lookup requires all the supporting classes to be put under the directory, web-inf\classes.

Starting the server from Tools > Start Server, or from the Signal Box always starts the current WebLogic Server. If the server is local, and has not been started, deploying the application will start the server.

A remote server cannot be started from Studio, and it should be running before the user can connect to it and deploy the application.

JNDI Names

Relations (JOIN condition)

If two beans share a relationship, the corresponding tables should ideally have the PK-FK relationship. During deployment, these dependencies are automatically resolved and the JOIN condition created. Specifying the JOIN condition manually requires the user to follow the given conditions:

Case 1 When join condition involves only participating beans table.

EXAMPLE

Bean A : Table X

Bean B : Table Y

Here each of the sub clauses must involve both the tables and the following are a few of the

valid JOIN conditions

X.ax = Y.ay AND X.bx = Y.by

X.ax =Y.by

The join condition, X.ax = X.cx is invalid as both LHS and RHS table are same (X).

Case 2 When join condition involves an additional third table, which joins the two participating bean's table

EXAMPLE

Bean A : Table X

Bean B : Table Y

Join Table : Z

Here, the JOIN condition can not have any other table.

X.ax = P.py AND X.ax = Z.az will be invalid.

A sub-clause cannot use both the tables, X and Y at the same time.

X.ax = Z.az AND X.bx = Y.by is invalid.

In the above example, the following are valid join conditions :

X.ax = Z.az AND Y.by = Z.bz

X.ax = Z.az

Though this involves only two tables, it is valid because table Z is the link table.

JMS server resources (Topics, Queues and ConnectionFactories)

If the embedded JMS server is being used then the Resources tool can be used to create topics, queues and ConnectionFactories. If the JMS server being used is an external server, the topics, queues and ConnectionFactories have to be created on the specific server, and use the same name while deploying.

If there are more than one JMS server configured in a domain, then the topic_name/queue_name must be unique across the JMS servers as it's JNDI name is bound on the application server.

Queries for EJB 1.1 Beans

CMP 1.1 beans require finder queries for defining the Finder methods. These queries can be created using the Query wizard while creating the bean or in the Bean Properties panel before deployment.

The query should use only the bean table for which query is being written, and no other table.

Creating WebLogic Archives

Developing applications in Studio creates archives and modules with Pramati xml files. To create archives with weblogic xmls

This creates the required WebLogic deployment descriptors an stores them inside the archive. This archive is now a WebLogic deployable archive, and can be commercially deployed on any other WebLogic server.

When using the option Export As Archive, ensure that the current server is WebLogic.

Debugging on WebLogic

Pramati Studio supports debugging applications on local as well as remote server. JSP Pages can be debugged only on the in-built server. To start the debugger, use Debug > Start from the main menu. If the server is on the local machine, then check the option, Application for J2EE. This starts the server in the debug mode. The application can now be deployed. The Debugger panel appears only after the breakpoints have been inserted.

If the server is on a remote machine

The VM options needed to start the server in debug mode are

-Xdebug -Xnoagent -Djava.compiler=NONE - Xrunjdwp:trans-
port=dt_socket,address=1234,suspend=n,serve r=y 

After adding the above option, the start server command appears as given below

java -ms64m -mx64m -classpath %CLASSPATH% "-Xdebug -Xno-
agent -Djava.compiler=NONE - Xrunjdwp:trans-
port=dt_socket,address=1234,suspend=n,server=y -
Dweblogic.Domain=mydomain -Dweblogic.Name=myserver "-
Dbea.home=E:\WLHome" - Dweblogic.management.pass-
word=mypassword -Dweblogic.ProductionModeEnabled=false -
Djava.security.policy=E:\WLHome\wlserver6.1/lib/
weblogic.policy"weblogic.Server 

This entry can also be entered in startWeblogic.cmd.

WebLogic Usage Restrictions


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX