0

Weblogic11gでJava6を実行しています。

私は、EJBを使用してデータベースと通信するWebサービスプロジェクトに取り組んでいます。現在、エラー処理に取り組んでいるため、Webサービスを呼び出す前にEJBをアンデプロイしてみました。私のEJBClientHelperクラスは次のようになります。

package mypackage.elkom.utils;

import java.io.Serializable;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import mypackage.elkom.ejb.beans.session.remote.ElkomRemote;

public class EJBClientHelper implements Serializable {

  /**
   * 
   */
  private static final long serialVersionUID = 1L;

  private ElkomRemote elkomRemote;

  private static final String ELKOM_JNDI =   "ElkomBean#mypackage.ejb.beans.session.remote.ElkomRemote";

  private Context ctx;

  private void prepareEjb3Connection() throws PropsFileException, NamingException {
      // Here's code for getting the ejbProviderURL from propsfile //
      props.put("java.naming.factory.initial", weblogic.jndi.WLInitialContextFactory");
      props.put("java.naming.provider.url",ejbProviderURL);
      ctx = new InitialContext(props);

 }

  public void setElkomRemote(ElkomRemote elkomRemote) {
    this.elkomRemote = elkomRemote;
  }

  public ElkomRemote getElkomRemote() throws NamingException, PropsFileException {
    prepareEjb3Connection();
    if(elkomRemote == null) {
    elkomRemote = (ElkomRemote)ctx.lookup(ELKOM_JNDI);
   }
   return elkomRemote;
  }

}

しかし、getElkomRemote();を使用すると 私はNamingExceptionの代わりにこのメッセージを受け取ります:

SEVERE: The object identified by: '678' could not be found.  Either it was has not been exported or it has been collected by the distributed garbage collector.; 
nested exception is: java.rmi.NoSuchObjectException: The object identified by: '678' could not be found.  
Either it was has not been exported or it has been collected by the distributed garbage collector.
javax.ejb.EJBException: The object identified by: '678' could not be found.  Either it was has not been exported or it has been collected by the distributed garbage collector.; 
nested exception is: java.rmi.NoSuchObjectException: The object identified by: '678' could not be found.  
Either it was has not been exported or it has been collected by the distributed garbage collector.
java.rmi.NoSuchObjectException: The object identified by: '678' could not be found.  Either it was has not been exported or it has been collected by the distributed garbage collector.

NamingExceptionの代わりにこのメッセージが表示される理由を知っている人はいますか?そして、おそらくそれを修正する方法は?

4

1 に答える 1

1

3つの例外カテゴリがあります。

  • システム例外
  • JVM例外
  • アプリケーションの例外

Αシステム例外は、コードのバグまたはJNDIルックアップの設定ミスなどのリソースの設定ミスが原因で発生する可能性があります。エンタープライズBeanがシステムエラーに直面した場合、通常はjavax.ejb.EJBExceptionをスローします。コンテナはEJBExceptionをRemoteExceptionでラップし、最後にRemoteExceptionがクライアントに返されます。それがあなたのケースで起こったことであり、それがあなたがRemoteExceptionを受け取った理由です。

システム例外はクライアントアプリケーションから処理できないため、チェックされていない例外としてスローする必要があります。

詳細については、次の記事を参照してください。

これがお役に立てば幸いです。

于 2012-08-20T20:43:32.377 に答える