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