- - PR -
EJBローカルインターフェースのlookupで"NameNotFoundException"となる
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2005-02-16 15:05
今までRemoteで動いていたセションEJBをLocalインターフェースに変更したところ、
ホームインターフェースlookupで"NameNotFoundException"となってしまいます。 色々資料を調べましたが、どうしても原因が判明しません。 どなたか教えて下さい。 動作環境は「Sun Java System Application Server Platform Edition 8.1 2005Q1」です。 JNDIブラウザーで見るとjndi-name「BusinessDelegate」が登録されていません。 下記のDD指定で「なぜ登録されないのか?」が分かりません。 === ejb-jar.xmlファイル ================================================== <?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns = "http://java.sun.com/xml/ns/j2ee" version = "2.1" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"> <display-name>Vol_Enterprise</display-name> <enterprise-beans> <session> <display-name>BusinessDelegate</display-name> <ejb-name>BusinessDelegate</ejb-name> <local-home>vol.businessfacade.BusinessDelegateHome</local-home> <local>vol.businessfacade.BusinessDelegate</local> <ejb-class>vol.businessfacade.BusinessDelegateBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Bean</transaction-type> <resource-ref> <res-ref-name>jdbc/jdbc-vol</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </session> </enterprise-beans> <assembly-descriptor/> </ejb-jar> === sun-ejb-jar.xmlファイル ============================================= <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 EJB 2.1//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-1.dtd"> <sun-ejb-jar> <enterprise-beans> <unique-id>9</unique-id> <ejb> <ejb-name>BusinessDelegate</ejb-name> <jndi-name>ejb/BusinessDelegateHome</jndi-name> <resource-ref> <res-ref-name>jdbc/jdbc-vol</res-ref-name> <jndi-name>jdbc/jdbc-vol</jndi-name> </resource-ref> <is-read-only-bean>false</is-read-only-bean> <gen-classes/> </ejb> </enterprise-beans> </sun-ejb-jar> === ホームインタフェース取得ソース ========================================== try { Context initial = new InitialContext(); Object objref = initial.lookup("ejb/BusinessDelegateHome"); BusinessDelegateHome home = (BusinessDelegateHome)objref; business = home.create(); } catch (NamingException e) { throw new RuntimeException(e); } catch (CreateException e) { throw new RuntimeException(e); } 以上、よろしくお願いします。 赤兵衛 |
|
投稿日時: 2005-02-16 16:06
sunのAPサーバは使用したことはないですが、weblogicですと
remoteではなくlocalなEJBを使用する場合、下記JNDIに関する 修正が必要になります。 <jndi-name> → <local-jndi-name> 同じような修正が必要でないか確かめられてはいかがでしょう。 |
|
投稿日時: 2005-02-16 16:46
(株)ぽちさん、有難うございます。
<local-jndi-name>に変更して確認しました。 デプロイはエラーなく完了しましたが、結果は同じで javax.naming.NameNotFoundException: BusinessDelegateHome not found となります。 なお、書籍を参考にホームインターフェースのlookupソースを Object objref = initial.lookup("java:comp/env/ejb/BusinessDelegateHome"); に変更して見ました。 結果は、下記の様にメッセージは若干異なっていますが、NGです。 javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/BusinessDelegateHome |
|
投稿日時: 2005-02-17 17:51
自己レスです。
Sun Microsystems社の下記の様な「Sun ONE Application Server 7」に関する資料がありました。 これによると、EJBをローカルインタフェースで使用するのは特殊な手法になり、Sun Java System Application Server Platform Edition 8.1でも同じだと思います。 下記に参考として記述内容を引用しました。 ======================================================================== The concept of a "local-jndi-name" is not present in the Sun ONE Application Server 7. So, assuming that the client component is a session bean, in the case of the Sun ONE Application Server 7, the equivalent snippets are: ejb-jar.xml: <session> <ejb-name>MemberManagementService</ejb-name> <home> com.examples.MemberManagementServiceHome</home> <remote> com.examples.MemberManagementServiceRemote</remote> <ejb-class> com.examples.MemberManagementServiceEJB</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <!—ejb-local-ref for accessing local interfaces --> <ejb-local-ref> <ejb-ref-name>PersonEJB</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <local-home>com.examples.PersonLocalHome</local-home> <local>com.examples.PersonLocal</local> <ejb-link>PersonEJB</ejb-link> </ejb-local-ref> Pay attention that since a "<ejb-link>PersonEJB</ejb-link>" is defined, there is no need to link the "<ejb-ref-name>" to a JNDI name inside the sun-ejb-jar.xml. So no equivalent additions are required inside the sun-ejb-jar.xml Client code for the Sun ONE Application Server 7 to access the PersonEJB from inside the MemberManagementService session bean through its local interface will look like: public Object getLocalPersonObject() throws ServiceLocatorException { Object object = objectsMap.get("java:comp/env/PersonEJB"); try { if ((object == null) && (context != null)) { object = context.lookup("java:comp/env/PersonEJB"); objectsMap.put(name, object); } return object; } catch (NamingException ne){ 以下省略 |
1