1 Reply Latest reply on Sep 13, 2002 10:22 AM by spieler

    Binding Local Interfaces to JNDI Problem

    prasanna

      Hi !
      Could somebody suggest me how to bind local interfaces
      to jndi so that it could be used in jsp and servlets in
      JBoss 3.0.

      My ejb name in ejb-jar.xml is CategoryEJB
      (It implements local interfaces and NOT the Remote)

      In "jboss.xml" I configured like
      this

      <ejb-name>CategoryEJB</ejb-name>
      <local-jndi-name>category/Category</local-jndi name>


      In "jboss-web.xml" I configured like this.
      (as <ejb-local-ref> tag is NOT supported see jboss-web_3_0.dtd)

      <ejb-ref>
      <ejb-ref-name>ejb/Category</ejb-ref-name>
      <jndi-name>category/Category</jndi-name>
      </ejb-ref>

      Finally I configured web.xml as following
      to be accessed by jsp.
      <ejb-local-ref>
      <ejb-ref-name>ejb/Category</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>....</local-home>
      ....
      </ejb-local-ref>

      The problems is it throws NamingException

      Caused by: javax.naming.NamingException: ejb-local-ref: ejb/Category, target not found, add valid ejb-link
      at org.jboss.web.AbstractWebContainer.linkEjbLocalRefs(AbstractWebContainer.java:651)


      Does anyone knows a solution to this problem or why this is happening ?

        • 1. Re: Binding Local Interfaces to JNDI Problem
          spieler

          Hi,
          since I currently only understand have of what I am doing here, but I think I just solved your problem (because it was mine too until some hours ago).

          You have to do two things:
          - declare that the EJB has a local interface
          - declare that your bean want to use the other bean

          wiht the descriptors below I was able to retrieve a Local home interface in the session bean like this:

          InitialContext context = new InitialContext();

          PropertyLocalHome propertyLocalHome
          = (PropertyLocalHome)context.lookup( "java:comp/env/ejb/evaluator/PropertyLocal" );


          I did it with XDoclet, below is what it generate in the ejb-jar.xml (it's for a session bean using an entity bean, but I hope it helps anyway):

          --- this is from the deployment description of the EJB:
          [...]

          [...]
          <local-home>de.lineas.evaluator.interfaces.EvaluationLocalHome</local-home>
          de.lineas.evaluator.interfaces.EvaluationLocal
          [...]

          [...]



          ---- this is in the bean descriptor which wants to use the local interface: -----
          [...]

          [...]
          <ejb-local-ref>
          <ejb-ref-name>ejb/evaluator/EvaluationLocal</ejb-ref-name>
          <ejb-ref-type>Entity</ejb-ref-type>
          <local-home>de.lineas.evaluator.interfaces.EvaluationLocalHome</local-home>
          de.lineas.evaluator.interfaces.EvaluationLocal
          <ejb-link>evaluator/Evaluation</ejb-link>
          </ejb-local-ref>
          [...]

          [...]


          Have fun
          Spieler