ヘッダーをスキップ
Oracle® Fusion Middleware Oracle WebLogic Server WLECのためのWebLogic Tuxedo Connector移行ガイド
11g リリース1(10.3.3)
B61643-01
  ドキュメント・ライブラリへ移動
ライブラリ
製品リストへ移動
製品
目次へ移動
目次

前
 
 

3 Tuxedo CORBA Simpappサンプルの変更方法

以下の項では、Oracle WebLogic Tuxedo Connectorを使用するようにWLECアプリケーションを変換する方法について説明します。この例では、Oracle WebLogic Tuxedo Connectorを使用して動作するようにWebLogic Server 6.1のexamples\wlec\ejb\simpappサンプルを変換する手順について説明します。

先に進む前に、「前提条件」を確認してください。

Tuxedo環境の変更方法

以下の項では、Oracle WebLogic Tuxedo Connectorで使用するためにTuxedo構成ファイルを変更する方法について説明します。

Tuxedo CORBA simpappサンプルの実行

Tuxedo環境を確認してWLEC simpappアプリケーションの実行を準備するには、Tuxedo CORBA simpappサンプルを実行する必要があります。

次の手順に従って、$TUXDIR/samples/corba/simpappにあるTuxedoサンプルを実行します。

  1. Tuxedo CORBA simpappサンプルの作業用コピーを作成します。インストールされているTuxedoからTuxedo CORBA simpappサンプルをコピーし、作業用のsimpappディレクトリに格納します。

  2. 作業用のsimpappディレクトリへ移動します。

  3. サンプルをビルドして実行します。

    1. Tuxedo環境を設定します。Windowsの場合は、シェル環境でset %TUXDIR%を実行します。Unixの場合は、$TUXDIR/tux.envを実行してTuxedo環境を設定する必要があります。

    2. C++コンパイラがPATHに含まれていることを確認します。

    3. JAVA_HOME環境変数をTuxedo Java JDKの場所に設定します。

    4. runmeスクリプトを実行して環境を設定します。CORBAオブジェクト操作のプログラミング・インタフェースを提供するクライアント・スタブが作成されます。作業ディレクトリの中に、Tuxedo環境の構成に使用するファイルが格納されたresultsディレクトリが作成されます。

    5. クライアントを実行します。

      java -DTOBJADDR=%TOBJADDR% -classpath %CLASSPATH% SimpleClient
      
    6. Tuxedoサーバーを停止します。

      tmshutdown -y
      

UBB構成ファイルの変更

作業用のTuxedo simpappディレクトリで、次の手順に従ってUBB構成を変更します。

  1. 作業ディレクトリのresults/ubbファイルの名前をresults/ubbdomainに変更します。

  2. viやワードパッドなどのテキスト・エディタを使用してubbdomainファイルを編集します。

  3. *SERVERSセクションにTuxedoゲートウェイ・サーバーを追加します。

    例:次のサーバーを追加します。

    DMADM SRVGRP=SYS_GRP SRVID=7
    GWADM SRVGRP=SYS_GRP SRVID=8
    GWTDOMAIN SRVGRP=SYS_GRP SRVID=9
    
  4. ubbdomainファイルを保存します。

例3-1は、変更後のubbdomainファイルの例です。変更されたセクションは太字で示されています。

例3-1 変更後のUBBファイル

*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

ドメイン構成の作成

作業用のTuxedo simpappディレクトリで、次の手順に従ってドメイン構成を作成します。

  1. viやメモ帳などのテキスト・エディタを使用してドメイン構成ファイルを作成します。最も簡単な方法はDMCONFIGのサンプル・コードを切り取り、エディタに貼り付けることです。

  2. 例3-2の太字山カッコ<>で囲まれたすべての項目を使用している環境の情報に置き換えます。

    例3-2 dmconfigファイル

         *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
    
  3. ファイルにDMCONFIGという名前を付けて作業用のsimpapp/resultsディレクトリに保存します。

Tuxedo環境のテスト

次の手順に従ってTuxedo構成を確認します。

  1. 新しいシェルで、作業用のsimpapp/resultsディレクトリに移動します。

  2. ご使用のプラットフォームのsetenvスクリプトを使用して環境を設定します。

  3. ubbdomainファイルをロードします。

    tmloadcf -y ubbdomain
    
  4. DMCONFIGファイルをロードします。

    set BDMCONFIG=<path_to_your_working_simpapp_example>/simpapp/results/bdmconfig
    dmloadcf -y dmconfig
    
  5. Tuxedoドメインを起動します。

    tmboot -y
    
  6. Tuxedo環境を確認します。

    java -DTOBJADDR=%TOBJADDR% -classpath %CLASSPATH% SimpleClient
    
  7. Tuxedoサーバーを停止します。

    tmshutdown -y
    

ejb-jar.xmlファイルの変更

viやメモ帳などのテキスト・エディタを使用して、接続プール記述子を削除し、trans-attributeを更新します。例3-3は、WLEC simpappサンプルのejb-jar.xmlで、IIOP接続プール記述子の参照を削除する方法を示したサンプル・コードです。このサンプルでは、

例3-3 CORBAサーバー・アプリケーションのサンプルXML構成ファイル

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

build.xmlファイルの更新

移行したアプリケーションのWebLogic環境へのコンパイルとデプロイを容易にするために、build.xmlファイルを以下に示します。build.xmlファイルの内容を例3-4に示すコードに置き換えます。

例3-4 更新後のbuild.xmlファイル

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

WLEC ConverterBeanの変更

例3-5は、wlec/ejb/simpappサンプルのConverterBean.javaファイルを変更し、Oracle WebLogic Tuxedo Connectorを使用してTuxedoと相互運用する方法を示したサンプル・コードです。

例3-5 変更後のConverterBean.javaファイル

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>
*/
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);
}
}
}

Oracle WebLogic Tuxedo Connectorの構成

以下の項では、WebLogic Serverと変更済みのWLECアプリケーションを接続するようにWebLogic Tuxedo Connectorを構成する方法を説明します。

  1. WTCサービスの作成

  2. ローカルTuxedoアクセス・ポイントの作成

  3. リモートTuxedoアクセス・ポイントの作成

  4. インポートされたサービスの作成

WTCサービスの作成

WebLogic Server管理コンソールを使用して、WTCサービスを作成および構成するには:

  1. 管理コンソールのナビゲーション・ツリーで、「相互運用性」を展開して「WTCサーバー」を選択します。

  2. 「WTCサーバー」ページで、「新規作成」をクリックします。

  3. 「新しいWTCサーバーの作成」ページの「名前」フィールドに、この構成を識別するMy_WLEC_Appを入力します。

  4. 「OK」をクリックします。

新しいWTCサービスがWTCサーバーのリストに表示されます。

ローカルTuxedoアクセス・ポイントの作成


注意:

ローカル・アクセス・ポイントのネットワーク・アドレスを構成する場合、使用するポート番号は、他のプロセスに割り当てられたポート番号とは異なる必要があります。たとえば、WebLogic Serverのリスニング・ポートが//mymachine:7001に割り当てられている場合、ネットワーク・アドレスを//mymachine:7001に設定すると無効になります。

ローカルTuxedoアクセス・ポイントを構成するには:

  1. 管理コンソールで、「相互運用性」を展開して「WTCサーバー」を選択します。

  2. 「WTCサーバー」ページで、WTCサービス名をクリックして、設定ページにアクセスします。

  3. 「ローカルAP」タブをクリックします。

  4. 「WTCローカル・アクセス・ポイント」ページで、以下のフィールドに次のとおり、値を入力します。

    • 「アクセス・ポイント」My_Local_WLS_Domを入力します。

    • アクセス・ポイントID」にexamplesと入力します。

  5. ネットワーク・アドレス」に、このローカル・ドメインをホストするWebLogic Server環境のネットワーク・アドレスとポートを入力します。たとえば、//my_WLS_machine:5678

  6. 「OK」をクリックします。

リモートTuxedoアクセス・ポイントの作成

リモートTuxedoアクセス・ポイントを構成するには:

  1. 管理コンソールで、「相互運用性」を展開して「WTCサーバー」を選択します。

  2. 「WTCサーバー」ページで、WTCサービス名をクリックします。

  3. 「リモートAP」タブをクリックします。

  4. 「WTCリモート・アクセス・ポイント」ページで、以下のフィールドに次のとおり、値を入力します。

    • 「アクセス・ポイント」My_WLEC_Domと入力します。

    • 「アクセス・ポイントID」TUXDOMと入力します。

    • 「ローカル・アクセス・ポイント」My_Local_WLS_Domと入力します。

  5. ネットワーク・アドレス」に、このリモート・ドメインをホストするTuxedo環境のネットワーク・アドレスとポートを入力します。たとえば、//my_TUX_machine:5678

  6. 「OK」をクリックします。

インポートされたサービスの作成

インポートされたサービスを構成するには:

  1. 管理コンソールで、「相互運用性」を展開して「WTCサーバー」を選択します。

  2. 「WTCサーバー」ページで、WTCサービス名をクリックします。

  3. 「インポート済み」タブをクリックします。

  4. 「WTCインポート・サービス」ページで、以下のフィールドに次のとおり、値を入力します。

    • リソース名」に、//simpappと入力します。

    • 「ローカル・アクセス・ポイント」に、My_Local_WLS_Domと入力します。

    • 「リモート・アクセス・ポイント・リスト」に、My_WLEC_Domと入力します。

    • リモート 名」に、//domain_idを入力します。domain_idは、Tuxedo UBBCONFIGファイルで指定されたDOMAINIDです。このCORBAドメインのユニークな識別子の最大長は、//を含めて15文字です。たとえば、//simpappff

  5. 「OK」をクリックします。

simpappサンプルの実行

simpappサンプルを実行するには、次の手順を実行します。

  1. 新しいシェルを開いて、作業用のTuxedo CORBA simpappサンプルに移動します。

  2. 環境変数を設定します。

    • Windows NTおよび2000システムの場合、次のコマンドを実行します。

      results\setenv.cmd
      
    • UNIXシステムの場合、次のコマンドを実行します。

      results\setenv.sh
      
  3. Tuxedoドメインを起動します。

    tmboot -y
    
  4. 新しいシェルを開いて、WebLogic Server WLEC simpappサンプルに移動します。

  5. 環境変数を設定します。以下のパラメータを更新します。


    注意:

    Windows NTまたは2000システムでは、setExamplesEnv.cmd scriptを変更して実行します。UNIXシステムの場合、WLEC simpappディレクトリに./config/examples/setExamplesEnv.sh scriptをコピーしてから、setExamplesEnv.shスクリプトを変更して実行します。

  6. simple.idlファイルをTuxedo CORBA simpappサンプルからWebLogic Server WLEC simpappサンプルにコピーします。

  7. 以下のコマンドを使用して、wlec_simpapp_corba.jarファイルをビルドします。

    ant
    
  8. WLSコンソールを使用してMy_WLEC_Appをサーバーに割り当てます。

  9. 以下のコマンドを入力して、クライアントを実行します。

    ant run
    

Javaアプリケーションは次のような出力を生成します。

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

サンプルの実行中に問題が発生する場合は、WTCのトレース機能を使用します。『Oracle Fusion Middleware Oracle WebLogic Server Tuxedo Connector管理ガイド』の「WebLogic Tuxedo Connectorのトラブル・シューティング」を参照してください。