3

weblogic 10.3.6 と EJB 3.0 を使用して小さな例を作成しました。SimpleService クラスを定義し、SimpleService クラスを JNDI 名にマップするために weblogic-ejb-jar.xml を定義し、EJB コンポーネントとして EAR ファイルにパックしてサーバーにデプロイします。デプロイが成功し、SimpleServiceBean という名前の ejb Bean が表示されます。その後、スタンドアロン アプリケーションを使用して、必要なすべての環境属性を使用して InitialContext を介して webloigc サーバーに接続し、その Bean を検索しようとします。ejb/SimpleService という名前で利用できると思いますが、その名前で見つけることができず、JNDI ツリー名を調べた後で初めて、SimpleService#ds/base/ejb/SimpleService という名前で利用できることがわかりました。何が起こっているのか理解するのを手伝ってください。公式の weblogic マニュアルで説明されているように、ejb/SimpleService で ejb Bean を使用できるようにするには、どのように ejb Bean を構成する必要がありますか? それとも、EJB Bean の正しい JNDI 名でしょうか?

私のクラスと構成は次のとおりです。

ds.base.ejb.SimpleServiceBean:

@Stateless(mappedName = "ServiceBean")
@TransactionAttribute(NEVER)
@ExcludeDefaultInterceptors
@Remote(SimpleService.class)
public class SimpleServiceBean implements SimpleService {
...
}

weblogic-ejb-jar.xml

<weblogic-ejb-jar>
    <weblogic-enterprise-bean>
        <ejb-name>ServiceBean</ejb-name>
        <jndi-name>ejb/ServiceBean</jndi-name>
        <enable-call-by-reference>True</enable-call-by-reference>
    </weblogic-enterprise-bean>
</weblogic-ejb-jar>

アプリケーション.xml:

<application>
    <display-name>web-app-ear</display-name>
    <module>
        <ejb>app-ejb-1.0-SNAPSHOT.jar</ejb>
    </module>
</application>

次に、スタンドアロンから取得してみます。

InitialContext context = new InitialContext(env);
SimpleService simpleService = (SimpleService)          
context.lookup("SimpleService#ds/base/ejb/SimpleService");
assert simpleService != null
4

2 に答える 2

1

glassfish.org にグローバル ポータルの JNDI 名に関するよくある質問があります http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#SessionBeanGlobalJNDINameAssignment JNDI 名 を割り当てるのではなく、定義された名前に依存するのがベスト プラクティスですEE 5 以降 (例: SimpleService#ds/base/ejb/SimpleService)

jndi-name コンフィグレーションを weblogic-ejb-jar.xml に追加すると、実際には ejb/ServiceBean として使用できるようになりますが、ejb-jar.xml で「オールド スクール」スタイルを定義する必要もあります。weblogic-ejb-jar.xml の詳細については、http://docs.oracle.com/cd/E23943_01/web.1111/e13719/ejb_jar_ref.htmを参照してください。

orcl docs には、dd に関する優れた概要もあります。 http://docs.oracle.com/cd/E23943_01/web.1111/e13719/understanding.htm#EJBPG129

10.3.x サーバー バージョンで作業していると仮定すると ...

于 2013-01-28T10:08:36.207 に答える