8 Replies Latest reply on Oct 30, 2003 5:40 PM by cfthomas

    JNDI Binding

    roby

      Hi
      can anyone help me with JNDI binding of reference names and JNDI names of my enterprise beans?
      Why my servlet can't find my bean if I use the JNDI name in lookup method? Where I mistake?
      I'm novice of JBoss.
      Thanks!

        • 1. Re: JNDI Binding

          Post the detail errors, relevent deployment
          descriptors and code snippets.

          Most likely you are using the wrong name,
          e.g. you didn't define the <ejb-ref>

          Regards,
          Adrian

          • 2. Re: JNDI Binding
            roby

            This is an example of my application:
            I have a bean with jndi name ConverterEJB and a Client that in its code use the following call:

            Object ref = context.lookup("ejb/SimpleConverter");

            how can I bind ConverterEJB with ejb/SimpleConverter??

            With J2EE RI we used deploytool to simply make this binding process!!
            Exception is:
            Caught an unexpected exception!
            javax.naming.NameNotFoundException: SimpleConverter not bound
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
            at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:256)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
            at sun.rmi.transport.Transport$1.run(Transport.java:148)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
            at java.lang.Thread.run(Thread.java:536)
            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
            at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
            at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:492)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
            at javax.naming.InitialContext.lookup(InitialContext.java:347)
            at converter.ConverterClient.main(ConverterClient.java:14)

            Thanks for your response!!
            roby

            • 3. Re: JNDI Binding

              Hi!

              Are you sure that the EJB is deployed without errors?

              Did you specified the JNDI-Name in the jboss.xml ?
              has to look like this:


              <ejb-name>SimpleConverter</ejb-name>
              <jndi-name>
              ejb/SimpleConverter
              </jndi-name>
              <local-jndi-name>
              ejb/SimpleConverterLocal
              </local-jndi-name>


              gts Peda

              • 4. Re: JNDI Binding
                roby

                Thanks for your response!
                I'm resolved my problem, this is my jboss.xml file:

                <enterprise-beans>

                <ejb-name>ConverterEJB</ejb-name>
                <jndi-name>ejb/SimpleConverter</jndi-name>


                <ejb-name>ConverterEJB</ejb-name>
                <jndi-name>ejb/SimpleConverter35</jndi-name>

                </enterprise-beans>



                In this way I'm able to run my EJB like "ejb/SimpleConverter", "ejb/SimpleConverter35" ect.
                Firstly I don't knowed what files are involved, and what tags...
                Excuse-me for my english, I'm Italian!!
                Grazie mille
                roby

                • 5. Re: JNDI Binding
                  roby

                  I'm in error...
                  My old post is not correct...
                  Only the second jndi-name work well, the first is ignored...
                  This is yet a result, but it's no possible I can't bind two jndi-names whit an ejb-name, in JBoss!!!
                  Anyone resolved this problem??
                  rgds
                  roby

                  • 6. Re: JNDI Binding

                    Well...
                    I don't think that you can give the same Bean 2 JNDI-Names with the jboss.xml (take a look at the DTD).

                    In fact, I don't think that it is very useful.

                    If you really want that I think you have to to a workaround and bind it with a selfwritten MBean.

                    (BTW greetings from Austria to Italy!)

                    ciao Peda

                    • 7. Re: JNDI Binding

                      You should be able to do this with 3.2
                      using the invoker proxy bindings.

                      You just bind it to the same protocol twice
                      with different jndi names.

                      Regards,
                      Adrian

                      • 8. Re: JNDI Binding
                        cfthomas

                        I have the same problem, wanting to assign 2 JNDI names to one EJB.
                        Could you give a sample how this could be done?

                        Thank you

                        Thomas