Hi there,

I'm trying to access an entity bean from a stateless session bean and I'm 
running into a "javax.naming.NameNotFoundException" while executing the 
followin statement:

ctx.lookup("java:/comp/env/ejb/MyBean");

ctx is an InitialContext without parameters. Both EJBs are running on the same 
server and and are in the same archive.

My ejb-jar.xml contains the following code (I will leave out tags like 
cmp-fields in this posting, btw: the session bean serves additionally as a web 
service):

<session>
        <display-name>Demo</display-name>
        <ejb-name>Demo</ejb-name>
        <home>com.test.DemoHome</home>
        <remote>com.test.Demo</remote>
        <service-endpoint>com.test.DemoSEI</service-endpoint>
        <ejb-class>com.test.DemoBean</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
        <ejb-ref>
                <ejb-ref-name>MyEntity</ejb-ref-name>
                <ejb-ref-type>Entity</ejb-ref-type>
                <home>com.all.MyEntityHome</home>
                <remote>com.all.MyEntity</remote>
                <ejb-link>MyEntity</ejb-link>
        </ejb-ref>
</session>

<entity>
        <description>Test entity bean</description>
        <ejb-name>MyEntity</ejb-name>
        <home>com.all.MyEntityHome</home>
        <remote>com.all.MyEntity</remote>
        <ejb-class>com.all.MyEntityBean</ejb-class>
        <persistence-type>Container</persistence-type>
        <prim-key-class>java.lang.String</prim-key-class>
        <reentrant>false</reentrant>
        <cmp-version>2.x</cmp-version>
        <abstract-schema-name>MyEntity</abstract-schema-name>
</entity>



My openejb-jar.xml contains the following code (I'll leave out things like 
cmp-mappings in this posting)

<enterprise-beans>
        <session>
                <ejb-name>Demo</ejb-name>
                <jndi-name>Demo</jndi-name>
        </session>
        <entity>
                <ejb-name>MyEntity</ejb-name>
                <jndi-name>MyEntity</jndi-name>
        </entity>
</enterprise-beans>


As I said before, a lookup is not possible. 

During several tries I changed the <jndi-name> for the entity bean in 
openejb-jar.xml  to <jndi-name>ejb/MyEntity</jndi-name> 

and the <ejb-ref-name> in ejb-jar-xml to
<ejb-ref-name>ejb/MyEntity</ejb-ref-name>


And magic: the lookup works. Unfortuanally I can not understand why. Is a 
leading "ejb/" required for jndi name? I don't think so, because I could not 
find anything similar in any tutorial. But what is the difference or what are 
the underlying rules?

Greets,

Markus

Schnell und einfach ohne Anschlusswechsel zur Lycos DSL Flatrate wechseln und 3 
Monate kostenlos ab effektiven 5,21 EUR pro Monat im ersten Jahr surfen.
http://www.lycos.de/startseite/online/dsl/index.html?prod=DSL&trackingID=email_footertxt

Reply via email to