10 Replies Latest reply on Apr 13, 2003 5:16 PM by dhinojosa

    Problems with JNDI Context

    nort

      Hi,

      I have an EJb with thes settings in jboss.jar:


      <ejb-name>TestEJB</ejb-name>
      <jndi-name>ejb/Test</jndi-name>
      <local-jndi-name>ejb/LocalTest</local-jndi-name>


      I mean the JNDI-name should be ejb/Test. But when I call the client with this name, an exception occurs. But when I call TestEJB then the EJB can be reached. Here my Client code:

      ....
      props.put(
      InitialContext.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
      props.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      ....


      InitialContext context = getContext();
      Object ref = context.lookup("TestEJB");
      TestEJBHome home = (TestEJBHome) javax.rmi.PortableRemoteObject.narrow(ref,TestEJBHome.class);
      TestEJBRemote myBean = home.create();


      Has someone an idea what to do. In Sun J2EE-Ri it works.

      Juraj

        • 1. Re: Problems with JNDI Context

          The snippet you posted should be in a
          jboss.xml alongside the ejb-jar.xml

          Try checking it against the dtd.
          If you can't figure it out post the full content.

          Regards,
          Adrian

          • 2. Re: Problems with JNDI Context
            nort

            hmmm XMLSPY say all is okay.

            Here my content of my jboss.xml (generated my xdoclet):

            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">

            <enterprise-beans>
            <!--
            To add beans that you have deployment descriptor info for, add
            a file to your XDoclet merge directory called jboss-beans.xml that contains
            the , and <message-driven></message-driven>
            markup for those beans.
            -->

            <ejb-name>TestEJB</ejb-name>
            <jndi-name>ejb/Test</jndi-name>
            <local-jndi-name>ejb/LocalTest</local-jndi-name>

            </enterprise-beans>
            <resource-managers></resource-managers>



            and the ejb-jar.xml (generated by xdoclet):
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
            <ejb-jar>
            <![CDATA[No Description.]]>
            <display-name>Generated by XDoclet</display-name>
            <enterprise-beans>
            <!-- Session Beans -->

            <![CDATA[]]>
            <ejb-name>TestEJB</ejb-name>
            com.test.TestEJBHome
            com.test.TestEJBRemote
            <local-home>com.test.TestEJBLocalHome</local-home>
            com.test.TestEJB
            <ejb-class>com.test.TestEJBBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>

            <!--
            To add session beans that you have deployment descriptor info for, add
            a file to your XDoclet merge directory called session-beans.xml that contains
            the markup for those beans.
            -->
            <!-- Entity Beans -->
            <!--
            To add entity beans that you have deployment descriptor info for, add
            a file to your XDoclet merge directory called entity-beans.xml that contains
            the markup for those beans.
            -->
            <!-- Message Driven Beans -->
            <!--
            To add message driven beans that you have deployment descriptor info for, add
            a file to your XDoclet merge directory called message-driven-beans.xml that contains
            the <message-driven></message-driven> markup for those beans.
            -->
            </enterprise-beans>
            <!-- Relationships -->
            <!-- Assembly Descriptor -->
            <assembly-descriptor>
            <!--
            To add additional assembly descriptor info here, add a file to your
            XDoclet merge directory called assembly-descriptor.xml that contains
            the <assembly-descriptor></assembly-descriptor> markup.
            -->
            <!-- finder permissions -->
            <!-- transactions -->
            <!-- finder transactions -->
            </assembly-descriptor>
            </ejb-jar>

            Can you see something?

            Thank you
            Juraj

            • 3. Re: Problems with JNDI Context
              nort

              hmmm XMLSPY say all is okay.

              Here my content of my jboss.xml (generated my xdoclet):

              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">

              <enterprise-beans>
              <!--
              To add beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called jboss-beans.xml that contains
              the , and <message-driven></message-driven>
              markup for those beans.
              -->

              <ejb-name>TestEJB</ejb-name>
              <jndi-name>ejb/Test</jndi-name>
              <local-jndi-name>ejb/LocalTest</local-jndi-name>

              </enterprise-beans>
              <resource-managers></resource-managers>



              and the ejb-jar.xml (generated by xdoclet):
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
              <ejb-jar>
              <![CDATA[No Description.]]>
              <display-name>Generated by XDoclet</display-name>
              <enterprise-beans>
              <!-- Session Beans -->

              <![CDATA[]]>
              <ejb-name>TestEJB</ejb-name>
              com.test.TestEJBHome
              com.test.TestEJBRemote
              <local-home>com.test.TestEJBLocalHome</local-home>
              com.test.TestEJB
              <ejb-class>com.test.TestEJBBean</ejb-class>
              <session-type>Stateless</session-type>
              <transaction-type>Container</transaction-type>

              <!--
              To add session beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called session-beans.xml that contains
              the markup for those beans.
              -->
              <!-- Entity Beans -->
              <!--
              To add entity beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called entity-beans.xml that contains
              the markup for those beans.
              -->
              <!-- Message Driven Beans -->
              <!--
              To add message driven beans that you have deployment descriptor info for, add
              a file to your XDoclet merge directory called message-driven-beans.xml that contains
              the <message-driven></message-driven> markup for those beans.
              -->
              </enterprise-beans>
              <!-- Relationships -->
              <!-- Assembly Descriptor -->
              <assembly-descriptor>
              <!--
              To add additional assembly descriptor info here, add a file to your
              XDoclet merge directory called assembly-descriptor.xml that contains
              the <assembly-descriptor></assembly-descriptor> markup.
              -->
              <!-- finder permissions -->
              <!-- transactions -->
              <!-- finder transactions -->
              </assembly-descriptor>
              </ejb-jar>

              Can you see something?

              Thank you
              Juraj

              • 4. Re: Problems with JNDI Context

                It looks ok to me,
                it should be bound at ejb/Test in global jndi

                Can you post the jar or a cutdown version
                that demonstrates the problem.

                Regards,
                Adrian

                • 5. Re: Problems with JNDI Context
                  nort

                  Client:

                  InitialContext context = getContext();
                  Object ref = context.lookup("ejb/TestEJB");

                  javax.naming.NameNotFoundException: TestEJB not bound

                  ==================

                  Object ref = context.lookup("TestEJB");
                  hallo

                  Client and EAR attached below

                  • 6. Re: Problems with JNDI Context
                    nort

                    any ideas?

                    • 7. Re: Problems with JNDI Context
                      haraldgliebe

                      You have to put the jboss.xml in the META-INF directory of the bean.jar next to the ejb-jar.xml, not in the META-INF of the ear.
                      Without the jboss.xml file JBoss uses the ejb-name as default jndi-name.

                      • 8. Re: Problems with JNDI Context
                        haraldgliebe

                        You need to put the jboss.xml file in the META-INF directory of the jar containing the EJBs, next to ejb-jar.xml, not in the META-INF directory of the EAR.
                        Without a jboss.xml JBoss uses the ejb-name as default jndi-name

                        • 9. Re: Problems with JNDI Context
                          haraldgliebe

                          You need to put the jboss.xml file in the META-INF directory of the jar containing the EJBs, next to ejb-jar.xml, not in the META-INF directory of the EAR.
                          Without a jboss.xml JBoss uses the ejb-name as default jndi-name.

                          • 10. Re: Problems with JNDI Context
                            dhinojosa

                            I didn't think you can access a local bean from a client app. Create a remote reference and you got your app.