5 Replies Latest reply on Jun 1, 2006 7:24 AM by Laurent PAGE

    Please help me: naming exception

    luca del core Newbie

      Hello People!
      I'm doing the porting of a project from SUN tu JBOSS. I'm using Netbeans 5.0 and jboss 4.0.2.
      Plese help me: I'm becoming mad...this error is very strange


      10:16:41,127 ERROR [LogInterceptor] EJBException in method: public abstract java.util.Collection SessBean1.CommessaCntrlLocal.readAll(), causedBy:
      javax.naming.NameNotFoundException: AnaClientiBean not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:49 at org.jnp.server.NamingServer.getBinding(NamingServer.java:49 at org.jnp.server.NamingServer.getObject(NamingServer.java:50


      The Source code is

      Context initial = new InitialContext();
      CommessaHomeLocal home = (CommessaHomeLocal)initial.lookup("java:comp/env/ejb/CommessaBean");

      AnaClientiHomeLocal home_clienti = (AnaClientiHomeLocal) initial.lookup("java:comp/env/ejb/AnaClientiBean");


      Another strange thing: in the first lookup (in the code above) i should do "java:comp/env/ejb/CommessaHomeLocal" but as it doesn't work I've changed to "java:comp/env/ejb/CommessaBean" and it works...
      But with the second lookup (in the code above) there is no way to make it work...
      I post the ejb-jar

      CommessaBean



      <ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
      <display-name>EntBean1</display-name>
      <enterprise-beans>
      <entity>
      <display-name>CommessaEB</display-name>
      <ejb-name>CommessaBean</ejb-name>
      <local-home>EntBean1.CommessaHomeLocal</local-home>
      <local>EntBean1.CommessaLocal</local>
      <ejb-class>EntBean1.CommessaBean</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      <reentrant>false</reentrant>
      <resource-ref>
      <res-ref-name>jdbc/prologic</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>
      </entity>
      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>
      <method>
      <ejb-name>CommessaBean</ejb-name>
      <method-name>*</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      AnaClientiBean


      <ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
      <display-name>AnaClienti</display-name>
      <enterprise-beans>
      <entity>
      <display-name>AnaClientiEB</display-name>
      <ejb-name>AnaClientiBean</ejb-name>
      <local-home>AnaClienti.AnaClientiHomeLocal</local-home>
      <local>AnaClienti.AnaClientiLocal</local>
      <ejb-class>AnaClienti.AnaClientiBean</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      <reentrant>false</reentrant>
      <resource-ref>
      <res-ref-name>jdcb/prologic</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>
      </entity>
      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>
      <method>
      <ejb-name>AnaClientiBean</ejb-name>
      <method-name>*</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      If someone has the solution...please help me...I'm going mad

        • 1. Re: Please help me: naming exception
          Laurent PAGE Newbie

          Hi,

          I had this kind of problem with local EJB sessions.
          COMP_NAME ( java:Comp/env ... ) doesn't work for me, I'm using only the JNDI name.

          /**
          * Retourne l'interface LocalHome du bean ApolloDataBean.
          * @see ApolloDataBean
          * @return ApolloDataLocalHome
          * @throws Exception
          */
          protected ApolloDataLocalHome getHome() throws Exception {
          Context ctx = new InitialContext();
          Object o = ctx.lookup(ApolloDataLocalHome.JNDI_NAME);
          /* ApolloDataLocalHome.JNDI_NAME = "ejb/ApolloDataLocal */
          ApolloDataLocalHome intf = (ApolloDataLocalHome) PortableRemoteObject.narrow(o, ApolloDataLocalHome.class);
          return intf;
          }

          /**
          * Evalue les contraintes sur le portefeuille passé en paramètre.
          * @param pfCode
          */
          public void evaluateMopPortfolio(int pfCode) throws ConstraintException {
          ApolloDataLocal dataBeanLocal;
          try {
          dataBeanLocal = this.home.create();
          Portefeuille ptf = (Portefeuille)dataBeanLocal.getEntity(this.mapSystemProperties, PojoClass.Portefeuille.fullName(), pfCode);

          ....


          dataBeanLocal.remove();
          } catch(Exception e) {
          logger.error("[Object]ConstraintsMgr,[method]evaluatePortfolioConstraint,[catch]Exception,[throw]ConstraintException,[Message]" + e.getMessage());
          throw new ConstraintException(ConstraintException.ERR_PTF);
          }
          this.constraintsResultat = Math.max(this.constraintsResultat,ConstraintConstants.EVAL_CTR_RESULT_WARNING);
          }


          • 2. Re: Please help me: naming exception
            luca del core Newbie

            THank you...but I can't understand: did you create a new class with these methods or you put in every bean file?

            • 3. Re: Please help me: naming exception
              Laurent PAGE Newbie

              My Example 2 Beans : ApolloData and ApolloMopConstraint
              I 'm Calling ApolloData inside ApolloMopConstraint.


              ----------------------------------------------------------------------
              jboss.xml
              ----------------------------------------------------------------------


              <ejb-name>ApolloMopConstraint</ejb-name>
              <jndi-name>ejb/ApolloMopConstraint</jndi-name>
              <local-jndi-name>ejb/ApolloMopConstraintLocal</local-jndi-name>



              <ejb-name>ApolloData</ejb-name>
              <jndi-name>ejb/ApolloData</jndi-name>
              <local-jndi-name>ejb/ApolloDataLocal</local-jndi-name>


              ----------------------------------------------------------------------
              ejb-jar.xml
              ----------------------------------------------------------------------

              <![CDATA[Description for ApolloMopConstraint]]>
              <display-name>Name for ApolloMopConstraint</display-name>
              <ejb-name>ApolloMopConstraint</ejb-name> com.apollo.server.interfaces.ApolloMopConstraintHome com.apollo.server.interfaces.ApolloMopConstraint <local-home>com.apollo.server.interfaces.ApolloMopConstraintLocalHome</local-home> com.apollo.server.interfaces.ApolloMopConstraintLocal <ejb-class>com.apollo.server.ejb.ApolloMopConstraintBean</ejb-class>
              <session-type>Stateless</session-type>
              <transaction-type>Container</transaction-type>



              <![CDATA[Description for ApolloData]]>
              <display-name>Name for ApolloData</display-name>
              <ejb-name>ApolloData</ejb-name>
              com.apollo.server.interfaces.ApolloDataHome
              com.apollo.server.interfaces.ApolloData <local-home>com.apollo.server.interfaces.ApolloDataLocalHome</local-home>
              com.apollo.server.interfaces.ApolloDataLocal
              <ejb-class>com.apollo.server.ejb.ApolloDataBean</ejb-class>
              <session-type>Stateless</session-type>
              <transaction-type>Container</transaction-type>



              ----------------------------------------------------------------------
              ApolloMopConstraint.java
              ----------------------------------------------------------------------
              Context ctx = new InitialContext();
              Object o = ctx.lookup("ejb/ApolloDataLocal");
              ApolloDataLocalHome home ;
              home = (ApolloDataLocalHome) PortableRemoteObject.narrow(o, ApolloDataLocalHome.class);
              ApolloDataLocal dataBeanLocal;
              dataBeanLocal = home.create();





              • 4. Re: Please help me: naming exception
                Laurent PAGE Newbie

                about the methods : it was just copy and paste from my classe..
                You can do as you want..

                • 5. Re: Please help me: naming exception
                  Laurent PAGE Newbie

                  it's me again ..
                  pb during the copy and past for the ejb-jar.xml


                  <!-- Session Beans -->

                  com.apollo.server.interfaces.ApolloMopConstraintHome
                  com.apollo.server.interfaces.ApolloMopConstraint
                  <local-home>com.apollo.server.interfaces.ApolloMopConstraintLocalHome</local-home>
                  com.apollo.server.interfaces.ApolloMopConstraintLocal
                  <ejb-class>com.apollo.server.ejb.ApolloMopConstraintBean</ejb-class>
                  <session-type>Stateless</session-type>
                  <transaction-type>Container</transaction-type>



                  <ejb-name>ApolloData</ejb-name>
                  com.apollo.server.interfaces.ApolloDataHome
                  com.apollo.server.interfaces.ApolloData <local-home>com.apollo.server.interfaces.ApolloDataLocalHome</local-home>
                  com.apollo.server.interfaces.ApolloDataLocal
                  <ejb-class>com.apollo.server.ejb.ApolloDataBean</ejb-class>
                  <session-type>Stateless</session-type>
                  <transaction-type>Container</transaction-type>




                  sorry