5 Replies Latest reply on Jun 26, 2011 1:06 AM by dvohra21

    EJB deployed but doesnt show up in JNDI tree on weblogic

    868795
      Hi,
      I have a sample EJB deployed on weblogic 10.3 server. My Bean class contains following code.
      ========================================================================

      @Stateless (mappedName = "DemoEJB")
      @TransactionManagement(TransactionManagementType.BEAN)

      public class DemoBean implements SessionBean {

           static final boolean verbose = true;
           private transient SessionContext ctx;
           private transient Properties props;


           @SuppressWarnings("deprecation")
           @Override
           public void setSessionContext(SessionContext ctx) throws EJBException,
                     RemoteException {
                // TODO Auto-generated method stub
                if (verbose)
                System.out.println("setSessionContext called");
                this.ctx = ctx;
                props = ctx.getEnvironment();
                
           }
           public String demoSelect()
      throws RemoteException
      {

      return("hello world");
      }

      }
      ===========================================================================

      I have created a jar file for the above class using eclipse and deployed it on weblogic. I can see the EJB in the <Deployment> on weblogic but it doesnt appear in <EJB> on JNDI tree view. Therefore i cannot access it from my client code (also written in Eclipse IDE).

      I will appreciate any guidance in this regard.

      Thanks
      Regards,
      Awais
        • 1. Re: EJB deployed but doesnt show up in JNDI tree on weblogic
          User696-Oracle
          It should be there under

          mappedName#name_of_Remote_businessInterface
          where name_of_Remote_businessInterface is the fully qualified name of the business interface of this session bean.

          For example, if you specify mappedName="bank" and the fully qualified name of the business interface is com.CheckingAccount, then the JNDI of the business interface is bank#com.CheckingAccount.

          http://download.oracle.com/docs/cd/E12840_01/wls/docs103/ejb30/annotations.html

          Regards,
          Sunil
          • 2. Re: EJB deployed but doesnt show up in JNDI tree on weblogic
            868795
            Thanks Sunil,

            I am new to Weblogic/EJB, so can you please explain it to me. Whenever I deploy .jar file for my EJB it just shows in deployments but not in EJB or JNDI Tree. I can access a default EJB placed in EJB tag on webserver, which is also visible on JNDI tree, from my client code. I have tried lots of different methods available on internet for creating and deploying the EJB but no success as of yet. Can you please help in this regard.

            Thanks
            • 3. Re: EJB deployed but doesnt show up in JNDI tree on weblogic
              870538
              Hi,

              i have the same problem with yours

              This is my annotation with EJB3.0:


              @Stateless(mappedName="ConSession")
              @Remote(ConBeanRemote.class)
              @Local(ConBean.class)



              and i have a weblogic-ejb-jar.xml to define my jndi name

              <?xml version="1.0" encoding="UTF-8"?>

              <weblogic-ejb-jar xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-ejb-jar"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                        http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
                        http://www.bea.com/ns/weblogic/weblogic-ejb-jar
                        http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd">

              <weblogic-enterprise-bean>
                   <ejb-name>ConSession</ejb-name>
              <stateless-session-descriptor>
                   <business-interface-jndi-name-map>
                        <business-remote>com.staffware.ConBeanRemote</business-remote>
                        <jndi-name>ConSession#com/staffware/ConBeanRemote</jndi-name>
                        </business-interface-jndi-name-map>
                        </stateless-session-descriptor>
                        <local-jndi-name>com/ConfigurationManagerBeanLocal</local-jndi-name>
                   </weblogic-enterprise-bean>
              </weblogic-ejb-jar>



              [ the most important: I also have specify JNDI in a java file like this
                        beanRemoteJNDIs.put("ConBeanRemote","ConSession#com/staffware/ConBeanRemote");
                   
                        beanLocalJNDIs.put("ConBean","java:comp/env/com/ConBean");
              ]

              and i can find the ConSession#com/staffware/ConBeanRemote in the jndi tree . but it shows like Multilevel directory tree

              and when i login the website and click the button

              .another error comes out :


              13:35:55,046 ERROR [EJBDelegate] Unable to lookup reference java:comp/env/com/ConBean for ConBean!
              javax.naming.LinkException: [Root exception is javax.naming.LinkException:  [Root exception is javax.naming.NameNotFoun
              dException: While trying to look up /app/ejb/CONFIG-ejb-2.0.jar#ConSession/local-home in /app/webapp/CO
              M/18328287.; remaining name '/app/ejb/CONFIG-ejb-2/0/jar#ConfigurationManagerSession/local-home']; Link Remaining Name:
              'java:app/ejb/CONFIG-ejb-2.0.jar#ConSession/local-home']; Link Remaining Name: 'com/ConBean'
              at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:104)
              at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:884)
              at weblogic.jndi.internal.ApplicationNamingNode.resolveObject(ApplicationNamingNode.java:187)

              。。。。。。。。。。。。。


              what should i do ?

              and should i specify the jndi name in the java file . the JNDI name defined in the weblogic is right?

              can you help me ?

              thanks very much in advance!
              • 4. Re: EJB deployed but doesnt show up in JNDI tree on weblogic
                dvohra21
                Use the mappedName and fully qualified remote interface name to lookup the remote bean.

                package sessionbean;
                @Stateless(mappedName="ConSession")
                @Remote
                public class ConBeanRemote { }


                InitialContext context = new InitialContext();
                ConBeanRemote beanRemote = (ConBeanRemote) context.lookup("ConSession#sessionbean.ConBeanRemote");

                Edited by: dvohra16 on Jun 25, 2011 6:36 PM
                • 5. Re: EJB deployed but doesnt show up in JNDI tree on weblogic
                  dvohra21
                  should i specify the jndi name in the java file .
                  The global JNDI name for a session bean remote business interface is derived from the mapped name and remote business interface name. The format of the global JNDI name is mappedName#qualified_name_of_businessInterface.

                  Edited by: dvohra16 on Jun 25, 2011 6:06 PM