WebSphere Application Server Version 6.1 Feature Pack for Web Services   
             オペレーティング・システム: AIX , HP-UX, i5/OS, Linux, Solaris, Windows, Windows Vista, z/OS

             目次と検索結果のパーソナライズ化

バージョン 5 からバージョン 6 にマイグレーションする EJB ラッパー適用アプリケーションの例外処理の調整

XML ベース Remote Procedure Call (JAX-RPC) 仕様の Java API が変更されたため、 WebSphere Application Server バージョン 5.1 でラップすることが可能であった EJB アプリケーションは、 基本 EJB アプリケーションの例外処理に対するコードを変更しない限り、バージョン 6 ではラップできません。

このタスクについて

基本的に、 JAX-RPC バージョン 1.1 仕様では以下のように記載されています。
リモート・メソッド・シグニチャーで宣言されるサービス固有の例外は、
チェックあり例外である必要があります。java.lang.Exception を直接的または間接的に拡張する必要がありますが、
RuntimeException であってはなりません。

そのため、 java.lang.Exception タイプまたは java.lang.Throwable タイプを直接使用することができなくなりました。仕様に準拠させるには、 サービス固有の例外を使用するアプリケーションを変更する必要があります。

プロシージャー

  1. サービス固有の例外を使用するアプリケーションを変更します。 例えば、既存の EJB が UserException と呼ばれるサービス固有の例外を使用しているとします。UserException 内には、java.lang.Exception タイプの ex と 呼ばれるフィールドがあります。WebSphere Application Server バージョン 6 で Web サービスを使用してアプリケーションを正常にラップするには、 UserException クラスを変更する必要があります。この例では、UserException を変更して、 ex のタイプを java.lang.Exception ではなく java.lang.String にすることが可能です。
    new UserException class:
    
    package irwwbase;
    
    /**
     * Insert the type's description here.
     * Creation date: (9/25/00 2:25:18 PM)
     * @author: Administrator
     */
    
    
    public class UserException extends java.lang.Exception {
    
           private java.lang.String _infostring = null;
           private java.lang.String ex;
    /**
     * UserException constructor comment.
     */
    
    public UserException() {
           super();
    }
    /**
     * UserException constructor comment.
     */
    public UserException (String infostring)
    {
           _infostring = infostring;
    } // ctor
    /**
     * Insert the method's description here.
     * Creation date: (11/29/2001 9:25:50 AM)
     * @param msg java.lang.String
     * @param ex java.lang.Exception
     */
    public UserException(String msg,String t) {
           super(msg);
           this.setEx(t);
           
           }
           /**
            * @return
            */
           public java.lang.String get_infostring() {
                  return _infostring;
           }
    
           /**
            * @return
            */
           public java.lang.String getEx() {
                  return ex;
           }
    
           /**
            * @param string
            */
           public void set_infostring(java.lang.String string) {
                  _infostring = string;
           }
    
           /**
            * @param Exception
            */
           public void setEx(java.lang.String exception) {
                  ex = exception;
           }
           
           public void printStackTrace(java.io.PrintWriter s) {  
             System.out.println("the exception is :"+ex);       
             }
    
    }
  2. 例外処理を使用するエンタープライズ Bean ですべての例外処理を変更します。 エンタープライズ Bean が新規例外を受け入れるようコード化されていることを確認する必要があります。 この例では、コードは以下のようになります。
    new EJB exception handling:
    
    try {
          if (isDistributed()) itemCMPEntity = itemCMPEntityHome.findByPrimaryKey(ckey);
          else itemCMPEntityLocal = itemCMPEntityLocalHome.findByPrimaryKey(ckey);
      } catch (Exception ex) {
           System.out.println("%%%%% ERROR: getItemInstance - CMPjdbc " + _className);
           ex.printStackTrace();
           throw new UserException("error on itemCMPEntityHome.findByPrimaryKey(ckey)",ex.getMessage());
       }
タスク・トピック    

ご利用条件 | フィードバック

最終更新: Jan 21, 2008 4:10:06 PM EST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/tejb_migrwrap.html