4 Replies Latest reply on Sep 21, 2007 10:37 AM by alexg79

    Remote Not bound -- Help me !

    sukar1205

      I am testing a customerBean class through a client class but its giving me remote not bound. I checked the JNDI tree and remote is NOT UNDER customerBean. a little help would be great to get this program running. All I am trying to do is add a customer in a table.

      Here is the code for client ....

      
      public class Client {
      
       /** Creates a new instance of Client */
       public static void main(String[] args) throws Exception
       {
       Connection conn;
       // Step 1: Load the JDBC driver.
       Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
       System.out.println("Driver Loaded.");
       // Step 2: Establish the connection to the database.
       String url = "jdbc:sqlserver://localhost:1433;database=kc";
       conn = DriverManager.getConnection(url, "sa", "hi");
       System.out.println("Got Connection.");
      
       Client c = new Client();
       CustomerRemote r = c.lookupCustomerBean();
       TempCustomer first = new TempCustomer();
       first.setId(20);
       first.setName("aaaa");
       r.addCustomer(first);
      }
      


      This is the lookupCustomerBean function which where it gives me remote not bound

       private CustomerRemote lookupCustomerBean() {
       try {
       Hashtable props = new Hashtable();
       props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
       props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       props.put("java.naming.provider.url", "localhost");
       Context c = new InitialContext(props);
       //HERE IS THE PROBLEM !!
       return (CustomerRemote)c.lookup("CustomerBean/remote");
       }
       catch(NamingException ne) {
       Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught", ne);
       throw new RuntimeException(ne);
       }
       }
      


      Please some one tell me what is wrong with this code. why is remote not under customerBean.

      Thanks in advance,


        • 1. Re: Remote Not bound -- Help me !
          sukar1205

          THis is the error

          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 sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           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:627)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
           at javax.naming.InitialContext.lookup(InitialContext.java:351)
           at ejb.Client.lookupCustomerBean(Client.java:92)
           at ejb.Client.main(Client.java:39)
          Exception in thread "main" java.lang.RuntimeException: javax.naming.NameNotFoundException: remote not bound
           at ejb.Client.lookupCustomerBean(Client.java:96)
           at ejb.Client.main(Client.java:39)
          Caused by: 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 sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           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:627)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
           at javax.naming.InitialContext.lookup(InitialContext.java:351)
           at ejb.Client.lookupCustomerBean(Client.java:92)
           ... 1 more
          


          • 2. Re: Remote Not bound -- Help me !
            jaikiran

            Can you post the contents of the JNDI tree and also your bean code.

            • 3. Re: Remote Not bound -- Help me !
              sukar1205

              I got it working inserting customers in the table..
              but now I have another problem.. I am trying to delete customers from the table but first i have to find them before deleting.

              This is my Bean class

              @Stateless
              public class CustomerBean implements CustomerRemote {
              
               @Resource(mappedName = "java:/SQL")
               private DataSource SQL;
              
               @PersistenceContext private EntityManager em;
              
               private Connection c = null;
              
               public CustomerBean() throws SQLException {
               c = SQL.getConnection();
               }
              
               public void addCustomer(TempCustomer a){
               em.persist(a);
               }
              
               public TempCustomer findCustomerbyID(int id) {
               return em.find(TempCustomer.class, id);
               }
              
               public void deleteCustomer(TempCustomer b) {
               em.remove(b);
               }
              }
              


              and this is my main again but this time I am only testing if I can find the customers.. then deleting them.

               public static void main(String[] args) throws Exception {
              
               Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
               String url = "jdbc:sqlserver://localhost:1433;database=jdocxpt";
               conn = DriverManager.getConnection(url, "sa", "dev");
               Client c = new Client();
               CustomerRemote r = c.lookupCustomerBean();
              
               //finding the customers
               TempCustomer found = r.findCustomerbyID(7);
              
               if(found.getId() != 0){
               r.deleteCustomer(found);
               }
               }
              

              if I comment this line of code c = SQL.getConnection(); i will get an exception saying cannot open connection but if it wasn't I get some other Exception and that Exception is

              Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
               at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:523)
               at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:66)
               at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:61)
               at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
               at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
               at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
               at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
               at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
               at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
               at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
               at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
              Caused by: java.lang.reflect.InvocationTargetException
               at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
               at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
               at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
               at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
               at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:511)
               at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:66)
               at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:61)
               at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
               at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
               at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
               at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
               at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
               at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
               at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
               at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
               at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
               at org.jboss.remoting.Client.invoke(Client.java:1550)
               at org.jboss.remoting.Client.invoke(Client.java:530)
               at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
               at $Proxy0.findCustomerbyID(Unknown Source)
               at ejb.Client.main(Client.java:52)
               at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
               at $Proxy0.findCustomerbyID(Unknown Source)
               at ejb.Client.main(Client.java:52)
              Caused by: java.lang.NullPointerException
               at ejb.CustomerBean.<init>(CustomerBean.java:46)
               at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
               at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
               at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
               at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
               at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:511)
               at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:66)
               at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:61)
               at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
               at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
               at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
               at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
               at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
               at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
               at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
               at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
               at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
              Java Result: 1
              


              I know you need to open a connection in the bean class to connect to the table to look for customer. But I think I am doing it wrong ... a small help would be great thanks for you help. i really appreciate it.

              • 4. Re: Remote Not bound -- Help me !
                alexg79

                Why are you using the data source directly?
                Not that it's the cause of your problem, but IMHO EJB3 Persistence should be used instead unless you have a good reason not to.

                Where did you deploy your data source? Could you show its deployment descriptor?

                Also, when you look up beans remotely, you need to add the application name to the path, like "MyApp/MyBean/remote".