0 Replies Latest reply: Jan 21, 2013 7:13 AM by Mirian RSS

    Help to understand EJB bean JNDI name

    Mirian
      Hi Guys.

      I made a small example using weblogic 10.3.6 and EJB 3.0. Define SimpleService class, define weblogic-ejb-jar.xml in order to map SimpleService class to JNDI name, pack it as EJB component in EAR file and deploy on server. Deployment is successful and I can see ejb bean with name SimpleServiceBean. After that using standalone application connect to webloigc server through InitialContext with all necessary environment attributes I try to lookup that bean. I assume that it will be available under name ejb/SimpleService but can't found it under that name and only after I was looking through a JNDI tree name I found out that it available under name SimpleService#ds/base/ejb/SimpleService. Help me to understand what is going on? How should I configure ejb bean in order that it will be available under ejb/SimpleService as it described in the official weblogic manual?

      My classes and configs are:
      SimpleServiceBean:
      @Stateless(mappedName = "ServiceBean")
      @TransactionAttribute(NEVER)
      @ExcludeDefaultInterceptors
      @Remote(SimpleService.class)
      public class SimpleServiceBean implements SimpleService {
      ...
      }

      weblogic-ejb-jar.xml
      <weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar
      http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd ">

      <weblogic-enterprise-bean>
      <ejb-name>ServiceBean</ejb-name>
      <jndi-name>ejb/ServiceBean</jndi-name>
      <enable-call-by-reference>True</enable-call-by-reference>
      <stateless-session-descriptor>
      <pool>
      <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
      </pool>
      </stateless-session-descriptor>
      </weblogic-enterprise-bean>
      </weblogic-ejb-jar>

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

      Then try to get it from standalone:
      InitialContext context = new InitialContext(env);
      SimpleService simpleService = (SimpleService) context.lookup("SimpleService#ds/base/ejb/SimpleService");
      assert simpleService != null

      UPD: ds/base/ejb it's a package where SimpleService class is situated.

      Edited by: Mirian on 21.01.2013 5:12