2 Replies Latest reply on Nov 12, 2006 1:43 AM by jaikiran

    Problem with jndi bindings: my SLSB's not bound

    blomqvie

      Hi!

      I have problems with jndi. I cant get reference to my SLSB:s remote interface with lookup.

      The servlet which is using the lookup

      
      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      
      InitialContext context = new InitialContext(props);
      th=(TuoteHallintaRemote)context.lookup("TuoteHallintaRemote.class.getName()");
      
      


      SLSB code:

      
      @Stateless
      public class TuoteHallintaBean implements TuoteHallintaRemote {
      
       @PersistenceContext(unitName="def")
       protected EntityManager em;
      
       public boolean lisaaTuote(String nimi, Integer hinta) {
      
       Tuote t = new Tuote(nimi, hinta);
       em.persist(t);
       return true;
       }
      
       public Collection<Tuote> listaaTuotteet() {
      
       Query query = em.createQuery("from Tuote t");
       ArrayList al = (ArrayList)query.getResultList();
       return al;
       }
      
      }
      
      


      Remote Interface code:

      
      @Remote
      public interface TuoteHallintaRemote {
      
       public Collection<Tuote> listaaTuotteet();
       public boolean lisaaTuote(String nimi, Integer hinta);
      }
      
      


      Jboss's log says:

      14:42:26,322 INFO [STDOUT] com.hajat.db.TuoteHallintaRemote not bound


      I can't figure this out!


        • 1. Re: Problem with jndi bindings: my SLSB's not bound
          blomqvie

          The lookup goes actually like this:

          th=(TuoteHallintaRemote)context.lookup(TuoteHallintaRemote.class.getName());

          not
          th=(TuoteHallintaRemote)context.lookup("TuoteHallintaRemote.class.getName()");

          • 2. Re: Problem with jndi bindings: my SLSB's not bound
            jaikiran

            If you have not specified any JNDI name then the bean by default gets bound to appName/BeanName/remote for remote interface or appName/BeanName/local. So assuming your application name is myApp and you are looking up a remote interface, the code will look like:

            Context ctx = new InitialContext();
            TuoteHallintaRemote remote = (TuoteHallintaRemote) ctx.lookup("myApp/TuoteHallintaBean/remote");