4 Replies Latest reply on Jul 25, 2005 10:29 AM by bill.burke

    jndi mapping with Trails example

    lpiccoli

      hi all,

      i am just a little puzzled with my own ejb3 SLSB deployment on Jboss 403. I have followed the trails examples having an JSP invoking a SLSB calling a Entity bean. Straight forward stuff. However i can't find where to do the JNDI mapping!! Hence at run time i get JNDI name not found exception in the JSP.

      The trails stuff has no Deployment Descriptors as i undestand or as i can find. So where is the JNDI mapping performed.... it is taken care of in the anonation?

      any help please.

      -lp

        • 1. Re: jndi mapping with Trails example
          kabirkhan

          By default it uses the fully qualified name of the remote/local interface class.

          You can override this using the jboss specific @RemoteBinding and @LocalBinding annotations

          http://docs.jboss.org/ejb3/tutorial/jndibinding/jndi.html

          • 2. Re: jndi mapping with Trails example
            lpiccoli

            hi all,

            i still can not get this dam EJB3 code to be bound to a JNDI name.. what do i have to do here?

            I have attached the SLSB code, the JSP code and the exception. The SLSB
            cannot bw found from the JNDI context. The ear seems to be deployed cleanly as there are no errors in the server.log

            This is such a trivial task but i can't seem to solve it.

            Any help is appreciated.

            ------SLSB code----
            package com.asteriski.asset.business;

            import com.asteriski.asset.entity.*;
            import javax.ejb.*;
            import javax.persistence.*;
            import java.sql.Timestamp;
            import java.util.*;

            @Stateless
            public class AssetBean implements Asset {

            @PersistenceContext (unitName="as")
            protected EntityManager em;

            public void addAsset (String name) {
            System.out.println( "addAsset");
            AssetEntity assetEntity = new AssetEntity (name);
            em.persist (assetEntity);

            }


            public Collection getAssets()
            {
            return em.createQuery("from Asset a").getResultList();


            }


            }


            ---------JSP snipp-----

            <%
            AssetBean ab = null;

            try {
            System.out.println( "Attempting context lookup");
            InitialContext ctx = new InitialContext();
            ab = (AssetBean) ctx.lookup(AssetBean.class.getName());
            System.out.println( "got context lookup");

            } catch (Exception e)
            {

            System.out.println( "Error context lookup " + e);
            //e.printStackTrace ();
            }

            %>


            ---------Exception-----


            13:52:31,003 INFO [STDOUT] Error context lookup javax.naming.NameNotFoundExcept
            ion: com.asteriski.asset.business.AssetBean not bound
            13:52:31,003 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception

            • 3. Re: jndi mapping with Trails example
              lpiccoli

              solved this problem.

              It seems that the jndi is bound to the interface class not the implementation class!

              -lp

              • 4. Re: jndi mapping with Trails example
                bill.burke

                Yes. You don't have reference to the bean class on the client and also, a bean class can have both a local and remote interface...

                The real reason for the default was so that you automatically had a compiler checked constant you could use to lookup the EJB.

                MyRemoteInterface.class.getName()