Skip navigation.

WLEC to WebLogic Tuxedo Connector Migration Guide

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents View as PDF   Get Adobe Reader

How to Modify the Tuxedo CORBA Simpapp Example

The following section provides an example of how to convert a WLEC application to use WebLogic Tuxedo Connector. This example provides information on the steps required to convert the WebLogic Server 6.1 examples\wlec\ejb\simpapp example to work using the WebLogic Tuxedo Connector. A complete migrated FactoryFinder example is available from the BEA dev2dev code library. Review the Prerequisites before proceeding.

 


How to Modify the Tuxedo Environment

This section provides information on how to modify the Tuxedo configuration files to use with WebLogic Tuxedo Connector.

Run the Tuxedo CORBA Simpapp Example

You should run the Tuxedo CORBA simpapp example to verify your Tuxedo environment and prepare to run the WLEC simpapp application.

Use the following steps to run the Tuxedo example located at $TUXDIR/samples/corba/simpapp:

  1. Create a working copy of the Tuxedo CORBA simpapp example. Copy the Tuxedo CORBA simpapp example from your Tuxedo installation and place it in your working simpapp directory.
  2. Change directories to your working simpapp directory.
  3. Build and run the example.
    1. Set your Tuxedo environment. Windows users set %TUXDIR% in your shell environment. Unix users need to set the Tuxedo environment by running $TUXDIR/tux.env.
    2. Make sure the C++ compiler is in your PATH.
    3. Set the JAVA_HOME environment variable to the location of your Tuxedo Java JDK.
    4. Set the environment by running the runme script. This will create the client stubbs that provide the programming interface for CORBA object operations. A results directory is created in your working directory that contains the files used to configure the Tuxedo environment.
    5. Run the Java client.
    6. java -DTOBJADDR=%TOBJADDR% -classpath %CLASSPATH% SimpleClient
    7. Shutdown the Tuxedo server.
    8. tmshutdown -y

Modify the UBB Configuration File

In your working Tuxedo simpapp directory, use the following steps to modify your UBB configuration:

  1. Rename the results/ubb file in your working directory as results/ubbdomain.
  2. Edit the ubbdomain file using a text editor, such as vi or WordPad.
  3. Add Tuxedo gateway servers to the *SERVERS section.
  4. Example: Add the following servers.

     DMADM SRVGRP=SYS_GRP SRVID=7
     GWADM SRVGRP=SYS_GRP SRVID=8
     GWTDOMAIN SRVGRP=SYS_GRP SRVID=9
  1. Save the ubbdomain file.

The following code is an example of a modified ubbdomain file. Changed sections are marked in bold.

Listing 3-1 Modified UBB File

*RESOURCES
     IPCKEY 55432
     DOMAINID simpapp
     MASTER SITE1
     MODEL SHM
     LDBAL N
*MACHINES
     "balto"
     LMID = SITE1
     APPDIR = "/tux_apps/corba/simpapp"
     TUXCONFIG = "/tux_apps/corba/simpapp/results/tuxconfig"
     TUXDIR = "/my_machine/tux/tuxedo8.1"
     MAXWSCLIENTS = 10
*GROUPS
     SYS_GRP
     LMID = SITE1
     GRPNO = 1
     APP_GRP
     LMID = SITE1
     GRPNO = 2
*SERVERS
     DEFAULT:
     RESTART = Y
     MAXGEN = 5
     TMSYSEVT
SRVGRP = SYS_GRP
     SRVID = 1
TMFFNAME
     SRVGRP = SYS_GRP
     SRVID = 2
     CLOPT = "-A -- -N -M"
TMFFNAME
     SRVGRP = SYS_GRP
     SRVID = 3
     CLOPT = "-A -- -N"
TMFFNAME
     SRVGRP = SYS_GRP
     SRVID = 4
     CLOPT = "-A -- -F"
simple_server
     SRVGRP = APP_GRP
     SRVID = 1
     RESTART = N

# The ISL handler is not needed for WTC.
# If you do not need it for other WLEC applications,
# it can be removed.
ISL
     SRVGRP = SYS_GRP
     SRVID = 5
     CLOPT = "-A -- -n //mymachine:2468 -d /dev/tcp"
DMADM
     SRVGRP = SYS_GRP
     SRVID = 7
GWADM
     SRVGRP = SYS_GRP
     SRVID = 8
GWTDOMAIN
     SRVGRP = SYS_GRP
     SRVID = 9
*SERVICES

Create a Domain Configuration

In your working Tuxedo simpapp directory, use the following steps to create a domain configuration:

  1. Create a domain configuration file using a text editor, such as vi or NotePad. The simplest method is to cut and paste the dmconfig code example into your editor.
  2. Replace all <bracketed> items with information for your environment.

Listing 3-2 dmconfig File

     *DM_RESOURCES
     VERSION=U22
     *DM_LOCAL_DOMAINS
     TUXDOM     GWGRP=SYS_GRP
                TYPE=TDOMAIN
                DOMAINID="TUXDOM"
                BLOCKTIME=20
                MAXDATALEN=56
                MAXRDOM=89
                DMTLOGDEV="<Path to domain TLOG device>"
                DMTLOGNAME="DMTLOG_TUXDOM"
     *DM_REMOTE_DOMAINS
          examples TYPE=TDOMAIN DOMAINID="examples"
     *DM_TDOMAIN
          TUXDOM NWADDR="<network address of Tuxedo domain>"
          examples NWADDR="<network address of WTC domain>"
     *DM_REMOTE_SERVICES
  1. Save the file as dmconfig in your working simpapp/results directory.

Test the Tuxedo Environment

Use the following steps to validate your Tuxedo configuration:

  1. In a new shell, change directories to your working simpapp/results directory.
  2. Set the environment using the setenv script for your platform.
  3. Load the ubbdomain file:
  4. tmloadcf -y ubbdomain
  5. .Load the dmconfig file:
  6. set BDMCONFIG=<path_to_your_working_simpapp_example>/simpapp/results/bdmconfig
    dmloadcf -y dmconfig
  7. Boot the Tuxedo domain
  8. tmboot -y
  9. Verify the Tuxedo environment.
  10. java -DTOBJADDR=%TOBJADDR% -classpath %CLASSPATH% SimpleClient
  11. Shutdown the Tuxedo server.
  12. tmshutdown -y

 


Modify the ejb-jar.xml File

Use a text editor such as Vi or Notepade to remove connection pool descriptors and update the trans-attribute. The following listing provides a code example on how to remove references to the IIOP connection pool descriptors in the WLEC simpapp example ejb-jar.xml.

Listing 3-3 Example XML Configuration File for a CORBA Server Application

.
.
.
<ejb-jar>
<enterprise-beans>
<session>
     <ejb-name>ejb</ejb-name>
     <home>examples.wlec.ejb.simpapp.ConverterHome</home>
     <remote>examples.wlec.ejb.simpapp.Converter</remote>
<ejb-class>examples.wlec.ejb.simpapp.ConverterBean</ejb-class>
     <session-type>Stateless</session-type>
     <transaction-type>Container</transaction-type>
<!-- Remove or comment out the following statements
     <env-entry>
          <env-entry-name>IIOPPoolName</env-entry-name>
          <env-entry-type>java.lang.String</env-entry-type>
          <env-entry-value>simplepool</env-entry-value>
     </env-entry>
-->
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
     <method>
     <ejb-name>ejb</ejb-name>
     <method-intf>Remote</method-intf>
     <method-name>*</method-name>
     </method>
     <trans-attribute>Supports</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

 


Update the build.xml File

A build.xml file is presented below to simplify compiling and deploying your migrated application in the Weblogic 8.1 environment. Use the following example code to replace the contents of the build.xml file.

Listing 3-4 Updated build.xml file

<project name="wlec-ejb-simpapp" default="all" basedir=".">

<!-- set global properties for this build -->
<property environment="env"/>
<property file="../../../../examples.properties"/>
<property name="build.compiler" value="${compiler}"/>
<property name="source" value="."/>
<property name="build" value="${source}/build"/>
<property name="dist" value="${source}/dist"/>
<property name="ejb_classes" value="Converter.java, ConverterHome.java, ConverterResult.java,
ProcessingErrorException.java, ConverterBean.java"/>
<property name="ejb_jar" value="wlec_simpapp_corba.jar"/>
<property name="client_classes" value="Converter.java, ConverterHome.java, ConverterResult.java,
ProcessingErrorException.java, Client.java"/>

<target name="all" depends="clean, init, compile_idl, compile_ejb, jar_ejb, appc, compile_client"/>

<target name="init">
<!-- Create the time stamp -->
     <tstamp/>
     <!-- Create the build directory structure used by compile
     and copy the deployment descriptors into it-->
     <mkdir dir="${build}"/>
     <mkdir dir="${build}/META-INF"/>
     <mkdir dir="${dist}"/>
     <copy todir="${build}/META-INF">
     <fileset dir="${source}">
     <include name="*.xml"/>
     <exclude name="build.xml"/>
     </fileset>
     </copy>
     </target>

<!-- Compile IDL stub classes into the build directory (jar preparation) -->
<target name="compile_idl">
     <exec executable="idlj" dir=".">
     <arg line="-td build -pkgPrefix Simple simple -pkgPrefix      SimpleFactory simple simple.idl" />
     </exec>
     <javac srcdir="${build}" destdir="${build}"
     classpath="${CLASSPATH};${build}"/>
     <delete>
     <fileset dir="${build}">
     <include name="*.java"/>
     </fileset>
     </delete>
     </target>

<!-- Compile ejb classes into the build directory (jar preparation) -->
<target name="compile_ejb">
     <javac srcdir="${source}" destdir="${build}"
     includes="${ejb_classes}"
     classpath="${CLASSPATH};${build}"/>
     </target>

<!-- Make a standard ejb jar file, including XML deployment descriptors -->
<target name="jar_ejb" depends="compile_ejb">
     <jar jarfile="${dist}/std_${ejb_jar}"
     basedir="${build}">
     </jar>
     </target>

<!-- Run appc to create the deployable jar file -->
     <target name="appc" depends="jar_ejb">
<echo message="Generating container classes in ${apps.dir}/${ejb_jar}"/>
     <wlappc debug="${debug}"
     iiop="true"
     source="${dist}/std_${ejb_jar}"
     output="${apps.dir}/${ejb_jar}"
     />
     </target>

<!-- Compile EJB interfaces & client app into the clientclasses directory
-->
     <target name="compile_client">
     <javac srcdir="${source}"
     destdir="${client.classes.dir}"
     includes="${client_classes}"
     />
     </target>

<target name="run">
<java classname="examples.wlec.ejb.simpapp.Client">
</java>
</target>

     <target name="clean">
     <delete dir="${build}"/>
     <delete dir="${dist}"/>
     </target>
</project>

 


Modify the WLEC ConverterBean

The following listing provides a code example on how to modify the wlec/ejb/simpapp example ConverterBean.java file to interoperate with Tuxedo using WebLogic Tuxedo Connector.

Listing 3-5 Modified ConverterBean.java file

package examples.wlec.ejb.simpapp;

import javax.ejb.*;
import java.io.Serializable;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.omg.CORBA.*;
import com.beasys.Tobj.*;
import com.beasys.*;

/*These come from WebLogic Enterprise Simpapp sample */
//import SimpleFactory;
//import SimpleFactoryHelper;
//import Simple;
import simple.SimpleFactory;
import simple.SimpleFactoryHelper;
import simple.Simple;

/**
* <font face="Courier New" size=-1>ConverterBean</font> is a stateless
* SessionBean.
* This bean illustrates:
* <ul>
* <li> Accessing ISL/ISH process and then a WebLogic Enterprise server
* <li> No persistence of state between calls to the SessionBean
* <li> Application-defined exceptions
* </ul>
*
* @author Copyright (c) 1999-2001 by BEA Systems, Inc. All Rights Reserved.
*/
public class ConverterBean implements SessionBean {

static SimpleFactory simple_factory_ref;

// -----------------------------------------------------------------
// private variables
private SessionContext ctx;
private Context rootCtx;
private ORB orb;

// -----------------------------------------------------------------
// SessionBean implementation

/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbActivate() {}

/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbRemove() {}

/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbPassivate() {}

/**
* Sets the session context.
*
* @param ctx SessionContext context for session
*/
  public void setSessionContext(SessionContext ctx) {
this.ctx = ctx;
}

// Interface exposed to EJBObject

/**
* This method corresponds to the <font face="Courier New" size=-1>create</font>
* method in the home interface <font
*face="CourierNew"size=-1>ConverterHome.java</font>.
* The parameter sets of these two methods are identical. When the client calls the
* <font face="Courier New" size=-1>ConverterHome.create</font> method, the
* container allocates an instance of the EJBean and calls the
* <font face="Courier New" size=-1>ejbCreate</font> method.
*
* @exception CreateException
* if there is an error while initializing the IIOP pool
* @see examples.wlec.ejb.simpapp.Converter
*/
public void ejbCreate () throws CreateException {
try {
// try {
// Properties p = new Properties();
// p.put(Context.INITIAL_CONTEXT_FACTORY,
// "weblogic.jndi.WLInitialContextFactory");
// InitialContext ic = new InitialContext(p);
// rootCtx = (Context)ic.lookup("java:comp/env");
// }
//catch (NamingException ne) {
// throw new CreateException("Could not lookup context");
// }

// Initialize the ORB.
String args[] = null;
Properties Prop;
Prop = new Properties();
Prop.put("org.omg.CORBA.ORBClass",
"weblogic.wtc.corba.ORB");

orb = (ORB)new InitialContext().lookup("java:comp/ORB");

initIIOPpool();
}
catch (Exception e) {
throw new CreateException("ejbCreate called: " + e);
}
}

/**
* Converts the string to uppercase.
*
* @param mixed string input data
* @return ConverterResult conversion result
* @exception examples.wlec.ejb.simpapp.ProcessingErrorException
* if there is an error while converting the string
*/
public ConverterResult toUpper(String mixed)
throws ProcessingErrorException
{
return convert("UPPER", mixed);
}

/**
* Converts the string to lowercase.
*
* @param mixed string input data
* @return ConverterResult conversion result
* @exception examples.wlec.ejb.simpapp.ProcessingErrorException
* if there is an error while converting the string
*/
public ConverterResult toLower(String mixed)
throws ProcessingErrorException
{
return convert("LOWER", mixed);
}

protected ConverterResult convert (String changeCase, String mixed)
throws ProcessingErrorException
{
String result;
try {
// Find the simple object.
Simple simple = simple_factory_ref.find_simple();

if (changeCase.equals("UPPER")) {
// Invoke the to_upper opeation on M3 Simple object
org.omg.CORBA.StringHolder buf = new org.omg.CORBA.StringHolder(mixed);
simple.to_upper(buf);
result = buf.value;
}
else
{
result = simple.to_lower(mixed);
}

}
catch (org.omg.CORBA.SystemException e) {
throw new ProcessingErrorException("Converter error: Corba system exception: " + e);
}
catch (Exception e) {
throw new ProcessingErrorException("Converter error: " + e);
}
return new ConverterResult(result);
}

// Private methods

/**
* Returns the WebLogic Enterprise Connectivity pool name.
*
* @return String IIOP pool name
*/
// private String getIIOPPoolName() throws ProcessingErrorException {
// try {
// return (String) rootCtx.lookup("IIOPPoolName");
//}
// catch (NamingException ne) {
// throw new ProcessingErrorException ("IIOPPoolName not found in context");
//}
//}

/**
* Initializes an IIOP connection pool.
*/

private void initIIOPpool() throws Exception {
try {
// Create the bootstrap object,
// Tobj_Bootstrap bootstrap = // BootstrapFactory.getClientContext(getIIOPPoolName());

// Use the bootstrap object to find the factory finder.
// org.omg.CORBA.Object fact_finder_oref =
// bootstrap.resolve_initial_references("FactoryFinder") ;
org.omg.CORBA.Object fact_finder_oref =
orb.string_to_object("corbaloc:tgiop:simpapp/FactoryFinder");

// Narrow the factory finder.
FactoryFinder fact_finder_ref =
FactoryFinderHelper.narrow(fact_finder_oref);

// Use the factory finder to find the simple factory.
org.omg.CORBA.Object simple_fact_oref =
fact_finder_ref.find_one_factory_by_id(SimpleFactoryHelper.id());

// Narrow the simple factory.
simple_factory_ref =
SimpleFactoryHelper.narrow(simple_fact_oref);

}
catch (org.omg.CosLifeCycle.NoFactory e) {
throw new Exception("Can't find the simple factory: " +e);
}
catch (CannotProceed e) {
throw new Exception("FactoryFinder internal error: " +e);
}
catch (RegistrarNotAvailable e) {
throw new Exception("FactoryFinder Registrar not available: " +e);
}
//catch (InvalidName e) {
// throw new Exception("Invalid name from resolve_initial_reference(): " +e);
//}
// catch (org.omg.CORBA.BAD_PARAM e) {
// throw new Exception("Invalid TOBJADDR=//host:port property specified: " +e);
// }
catch (org.omg.CORBA.UserException e) {
throw new Exception("Unexpected CORBA user exception: " +e);
}
catch (org.omg.CORBA.SystemException e) {
throw new Exception("CORBA system exception: " +e);
}
}
}

 


Configure WebLogic Tuxedo Connector

Use the following steps to configure WebLogic Tuxedo Connector to connect WebLogic Server and the modified WLEC application:

Create a WTC Service

  1. Select the WebLogic Tuxedo Connector node in the left panel.
  2. Click Configure a new WTC Service.
  3. Enter My_WLEC_App to identify this configuration in the name field.
  4. Click Create.

Create a Local Tuxedo Access Point

  1. Click the WebLogic Tuxedo Connector node.
  2. Select the WTC Server instance and click to expand the node.
  3. Click the Local Tuxedo Access Points node.
  4. Click Configure a new Local Tuxedo Access Point.
  5. In Access Point, enter My_Local_WLS_Dom.
  6. In Access Point Id, enter examples.
  7. In Network Address, enter the network address and port of the WebLogic Server environment that will host this local domain.
  8. Example: //my_WLS_machine:5678

  9. Click Create.

Create a Remote Tuxedo Access Point

  1. Click the WebLogic Tuxedo Connector node.
  2. Select the WTC Server instance and click to expand the node.
  3. Click the Remote Tuxedo Access Points node.
  4. Click Configure a new Remote Tuxedo Access Point.
  5. In Access Point, enter My_WLEC_Dom.
  6. In Access Point Id, enter TUXDOM.
  7. In Local Access Point, enter My_Local_WLS_Dom.
  8. In Network Address, enter the network address and port of the Tuxedo environment that will host this remote domain.
  9. Example: //my_TUX_machine:5678

  10. Click Create.

Create an Imported Service

  1. Click the WebLogic Tuxedo Connector node.
  2. Select the WTC Server instance and click to expand the node.
  3. Click the Imported Services node.
  4. Click Configure a new Imported Service.
  5. In Resource Name, enter //simpapp.
  6. In Local Access Point, enter My_Local_WLS_Dom.
  7. In Remote Access Point List, enter My_WLEC_Dom.
  8. Click Create.

 


Run the simpapp Example

  1. Open a new shell and change directories to your working Tuxedo CORBA simpapp example.
  2. Set environment variables.
  3. NT\2000 users run the following command: results\setenv.cmd

    Unix users run the following command: results\setenv.sh

  4. Boot the Tuxedo domain
  5. tmboot -y
  6. Open a new shell and change directories to your WebLogic Server WLEC simpapp example.
  7. Set environment variables. Update the following parameters:

Note: NT/2000 users modify and run the setExamplesEnv.cmd. Unix users copy ./config/examples/setExamplesEnv.sh script to your WLEC simpapp directory, then modify and run the setExamplesEnv.sh script.

  1. Copy the simple.idl file from the Tuxedo CORBA simpapp example to your WebLogic Server WLEC simpapp example.
  2. Build the wlec_simpapp_corba.jar file using ant.
  3. Enter the following command: ant

  4. Use the WLS console to target My_WLEC_App to the server.
  5. Run the client.
  6. Enter the following command: ant run

The Java application generates the following output:

Beginning simpapp.Client...

Start of Conversion for: It Works

Converting to lower case: It Works

...Converted: it works

Converting to upper case: It Works
.
..Converted: IT WORKS

Removing Converter

End simpapp.Client...

If you have a problem running the example, use the WTC tracing feature. See Monitoring the WebLogic Tuxedo Connector.

 

Back to Top Previous Next