8 Replies Latest reply on Nov 13, 2002 8:25 PM by adrian.brock

    yet another jndi question...

    craighamilton

      I have deployed an ejb but cannot seem to get a reference to it via jndi.

      I have attached the results from jndiview, the code in the client, and the error message seen on the client.

      Any help much appreciated.

      craig



      Here is the results from jndiview

      file%/usr/local/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/ejbbudgeting.jar

      java:comp
      Activity

      env
      org.jnp.interfaces.NamingContext


      I am trying to access this bean from a client vm on a different computer with the following code:

      props.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      props.put("java.naming.provider.url","jnp://192.168.0.15:1099");
      props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
      props.put("jnp.socketFactory","org.jnp.interfaces.TimedSocketFactory");
      Context ctx = new InitialContext(props);

      Object obj = ctx.lookup("Activity");


      I get the following error:

      [java] javax.naming.NameNotFoundException: Activity not bound
      [java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
      [java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
      [java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
      [java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:464)
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:443)
      [java] at javax.naming.InitialContext.lookup(InitialContext.java:350)
      [java] at com.keycurve.ejb.ActivityClient.main(ActivityClient.java:17)

        • 1. Re: yet another jndi question...

          No, it is the same one that everybody asks :-)

          Look in the global namespace, it is probably
          bound as your <ejb-name>
          java:comp is only available from inside the bean.

          Regards,
          Adrian

          • 2. Re: yet another jndi question...
            craighamilton

            In my code which looks up the ejb, it is using the value of ejb-name.

            The jndiview seems to show it is bound as Activity also...

            Not sure what I am missing here.

            thanks,

            craig

            • 3. Re: yet another jndi question...

              Try posting your ejb-jar.xml and jboss.xml

              Also, add some code to list the initial context
              using the enumeration. This will tell you what is
              available.

              Regards,
              Adrian

              • 4. Re: yet another jndi question...
                craighamilton

                Here is my jboss.xml, and the message when I dump the context list.

                thanks,

                craig

                ejb-jar.xml
                -=-=-=-=-=-
                <?xml version = '1.0' encoding = 'UTF-8'?>
                <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
                <ejb-jar>
                <enterprise-beans>

                Entity Bean - CMP
                <display-name>Activity</display-name>
                <ejb-name>Activity</ejb-name>
                <local-home>com.keycurve.ejb.ActivityHome</local-home>
                com.keycurve.ejb.Activity
                <ejb-class>com.keycurve.ejb.ActivityBean</ejb-class>
                <persistence-type>Container</persistence-type>
                <cmp-version>2.x</cmp-version>
                <abstract-schema-name>activity</abstract-schema-name>
                <table-name>kcactivity</table-name>
                <cmp-field>
                <field-name>activityID</field-name>
                <column-name>activityid</column-name>
                <not-null/>
                </cmp-field>
                <cmp-field>
                <field-name>year</field-name>
                <column-name>year</column-name>
                <not-null/>
                </cmp-field>
                <cmp-field>
                <field-name>description</field-name>
                <column-name>description</column-name>
                <not-null/>
                </cmp-field>
                <prim-key-class>com.keycurve.ejb.ActivityPK</prim-key-class>
                False

                </enterprise-beans>
                </ejb-jar>


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

                <ENTERPRISE-BEANS>

                <EJB-NAME>Activity</EJB-NAME>
                <JNDI-NAME>Activity</JNDI-NAME>

                </ENTERPRISE-BEANS>




                context dump

                run.client:
                [java] Item: XAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
                [java] Item: RMIXAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
                [java] Item: UserTransactionSessionFactory: org.jboss.tm.usertx.server.UserTran
                [java] Item: topic: org.jnp.interfaces.NamingContext
                [java] Item: queue: org.jnp.interfaces.NamingContext
                [java] Item: ConnectionFactory: org.jboss.mq.SpyConnectionFactory
                [java] Item: RMIConnectionFactory: org.jboss.mq.SpyConnectionFactory

                • 5. Re: yet another jndi question...
                  craighamilton

                  This is the code to get the context dump. Is using "" correct?

                  thanks,

                  craig


                  NamingEnumeration enum = ctx.list("");
                  while(enum.hasMoreElements())
                  {
                  System.out.println("Item: " + enum.nextElement());
                  }

                  • 6. Re: yet another jndi question...

                    You cannot access LocalHome over RMI,
                    it is only available in the same VM.

                    If you are in the same VM, use new InitialContext();

                    Regards,
                    Adrian

                    • 7. Re: yet another jndi question...
                      craighamilton

                      Adrian,

                      First, thanks for the help, I appreciciate it.

                      I am running the client from a different vm, so I am trying to obtain a reference to the remote interface for the ejb.

                      Don't I need to create the InitialContext as I am for this?

                      thanks again,

                      craig



                      • 8. Re: yet another jndi question...

                        You only have in the ejb-jar.xml you posted.

                        Regards,
                        Adrian