6 Replies Latest reply on Feb 8, 2007 1:29 PM by strunker

    Remote not bound

    strunker

      Hi,

      I have a stateless session bean with the same local and remote interface. Lookup for local interface from my webapp works fine, but the lookup for the remote interface fails with:

      javax.naming.NameNotFoundException: remote not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
      at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
      at java.lang.Thread.run(Thread.java:595)
      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:126)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at BeanTestUtil.getRemoteUserManager(BeanTestUtil.java:40)
      ...

      Here's my bean declaration:

      @Local
      @Remote
      public interface UserManager {
      ...
      }

      @Stateless
      @Local(UserManager.class)
      @Remote(UserManager.class)
      public class UserManagerBean implements UserManager {
      ...
      }

      And here's the lookup:

      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      context = new InitialContext(props);
      contect.lookup("TestEAR/UserManagerBean/remote");

      And here's the output of JNDIView:

      Global JNDI Namespace
      ...
      +- TestEAR(class: org.jnp.interfaces.NamingContext)
      | +- UserManagerBean (class: org.jnp.interfaces.NamingContext)
      | | +- local (proxy: $Proxy137 implements interface org.community.ejb.business.UserManager,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
      | | +- remote (proxy: $Proxy136 implements interface org.community.ejb.business.UserManager,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
      ...


      I use JBoss 4.0.5 with EJB3.0 (from WebInstaller)

      Has anybody an idea what's going wrong?

      Strunker

        • 1. Re: Remote not bound
          strunker

          Nobody has an idea?

          If I posted in the wrong forum please move this topic to the right one.

          Best regards,
          Strunker

          • 2. Re: Remote not bound
            jaikiran

            Try this:

            Context context = new InitialContext();
            context.lookup("TestEAR/UserManagerBean/remote");


            instead of :


            Properties props = new Properties();
            props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
            props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
            props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
            context = new InitialContext(props);
            contect.lookup("TestEAR/UserManagerBean/remote");




            • 3. Re: Remote not bound
              alrubinger

              Also, you can't declare @Local and @Remote on the same interface...

              S,
              ALR

              • 4. Re: Remote not bound
                strunker

                Thank you for your answers, but I still have the same problems.

                @jaikiran:
                When I do like you've posted, I get the following exception:

                javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial


                @ALRubinger
                I tried also your suggestion, but I still get the same exception.
                My code looks as following now:

                @Stateless
                @Local(org.community.ejb.business.local.UserManager.class)
                @Remote(org.community.ejb.business.remote.UserManager.class)
                public class UserManagerBean implements org.community.ejb.business.local.UserManager, org.community.ejb.business.remote.UserManager {
                ...
                }

                @local
                public interface UserManager {
                ...
                }

                @remote
                public interface UserManager {
                ...
                }

                Local and remote interfaces are in different packages.

                Do you have any more ideas how I can call my bean remote?

                Best regards,
                Strunker

                • 5. Re: Remote not bound
                  strunker

                  It is getting strange. When I run my client code (JUnitTest) in debug mode with a breakpoint set, everything works fine now. But in normal mode I still get the exception:

                  javax.naming.NameNotFoundException: remote not bound

                  I really don't understand what's going on. What's different in debug mode? Maybe the jar files I need in classpath: Which jars do I need for a remote connection with JBoss 4.0.5 and EJB3?

                  I hope somebody can help me!

                  • 6. Solved!
                    strunker

                    I solved my problem.

                    The problem was that my Java IDE (idea) started a redeployment automatically when I started the JUnits tests. So there were no beans I could access.