简体   繁体   中英

ejb 3.1, weblogic 12c, java 1.6 Jndi Lookup issue

I have problem in configuring JNDI lookup for ejb3.1 and weblogic 12c, jdk1.6

@Remote
public interface Bank{

    public String accounts();

}

@Stateless(name="BankSession")
public class BankSessionBean implements Bank{

    @Override
    public String accounts() {
                 ////////    }

ejb-jar.xml:   

    <enterprise-beans>
        <session>
            <display-name>BankSession</display-name>
            <ejb-name>BankSession</ejb-name>
            <business-remote>com.examples.Bank</business-remote>
            <ejb-class>com.examples.BankSessionBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Bean</transaction-type>
        </session>
    <enterprise-beans>

weblogic-ejb-jar.xml:

 <weblogic-enterprise-bean>
    <ejb-name>BankSession</ejb-name>    
    <jndi-name>BankSession</jndi-name>
  </weblogic-enterprise-bean>


client code: 

When i start using Jndi Look up using this syntax java:comp/env/ejb/BankSession

Its giving following error.

javax.naming.NameNotFoundException: While trying to lookup 'java:comp/env/ejb/BankSession' didn't find subcontext.

Here ejbbean and client code runs on different jvm's.

Which Jndi look up should i use ?

  1. java:comp/env/ejb/BankSession'
  2. java:global/applicationName/moduleName/BankSession
  3. java:module/BankSession
  4. java:app/moduleName/BankSession

java:comp/env/ejb/BankSession is working fine with ejb 3.0 and oc4j server.

When i migrate to ejb3.1 and weblogic 12c, its not working.

I even tried without using weblogic deployment xml files. Same issue encountered.

How should i configure my Jndi here ? Please help as i am facing this issue since long time.

For a lookup in the form of java:comp/env/... you need an EJB ref in the deployment descriptor of the component that does the lookup! java:comp/env/... is always relative to the component that does the lookup.

A lookup name that is independent of the actual component that does the lookup and works from anywhere inside your application is 4.: java:app/moduleName/...

java:global/appName/... will fail if you decide to rename your ear file one day. java:module/... only works inside a component that is part of the same module. So 4. is IMO the best alternative.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM