4 Replies Latest reply on Jul 19, 2006 3:38 PM by Vivek Srivastav

    java.lang.ClassNotFoundException

    Vivek Srivastav Newbie

      When I am making a call to client.addListener(handler,locator), I am getting the following error message:

      this.port = port;
       serverName = server;
       System.out.println();
       System.out.println("socket://" + serverName + ":" + String.valueOf(port));
       locator = new InvokerLocator("socket://" + serverName + ":" + String.valueOf(port));
       client = new Client(locator);
       client.connect();
       handler = new ClientCallbackHandler();
       client.addListener(handler, locator);
      


      Error
       [java] socket://localhost:6034
       [java] Class Not found: [Ljava.lang.StackTraceElement;
       [java] java.lang.ClassNotFoundException: [Ljava.lang.StackTraceElement;
       [java] at org.apache.tools.ant.AntClassLoader.findClassInComponents(Ant
      ClassLoader.java:1149)
       [java] at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.
      java:1090)
       [java] at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.
      java:966)
       [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       [java] at org.jboss.remoting.loading.RemotingClassLoader.loadClass(Remo
      tingClassLoader.java:50)
       [java] at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.r
      esolveClass(ObjectInputStreamWithClassLoader.java:139)
       [java] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.
      java:1543)
       [java] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.jav
      a:1465)
       [java] at java.io.ObjectInputStream.readArray(ObjectInputStream.java:15
      90)
       [java] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:
      1298)
       [java] at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream
      .java:1917)
       [java] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.ja
      va:1841)
       [java] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStrea
      m.java:1718)
       [java] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:
      1304)
       [java] at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream
      .java:1917)
       [java] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.ja
      va:1841)
       [java] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStrea
      m.java:1718)
       [java] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:
      1304)
       [java] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:3
      49)
       [java] at org.jboss.remoting.serialization.impl.java.JavaSerializationM
      anager.receiveObject(JavaSerializationManager.java:128)
       [java] at org.jboss.remoting.marshal.serializable.SerializableUnMarshal
      ler.read(SerializableUnMarshaller.java:66)
       [java] at org.jboss.remoting.transport.socket.SocketClientInvoker.trans
      port(SocketClientInvoker.java:279)
       [java] at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInv
      oker.java:143)
       [java] at org.jboss.remoting.Client.invoke(Client.java:525)
       [java] at org.jboss.remoting.Client.addListener(Client.java:720)
       [java] at org.jboss.remoting.Client.addListener(Client.java:685)
       [java] at org.vss.service.license.client.LicenseClient.<init>(Unknown S
      ource)
       [java] at org.vss.service.license.client.LicenseClient.<init>(Unknown S
      ource)
       [java] at TestLicense.testLicenseClient(Unknown Source)
       [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
      sorImpl.java:39)
       [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
      hodAccessorImpl.java:25)
       [java] at java.lang.reflect.Method.invoke(Method.java:585)
       [java] at junit.framework.TestCase.runTest(TestCase.java:154)
       [java] at junit.framework.TestCase.runBare(TestCase.java:127)
       [java] at junit.framework.TestResult$1.protect(TestResult.java:106)
       [java] at junit.framework.TestResult.runProtected(TestResult.java:124)
       [java] at junit.framework.TestResult.run(TestResult.java:109)
       [java] at junit.framework.TestCase.run(TestCase.java:118)
       [java] at junit.framework.TestSuite.runTest(TestSuite.java:208)
       [java] at junit.framework.TestSuite.run(TestSuite.java:203)
       [java] at junit.textui.TestRunner.doRun(TestRunner.java:116)
       [java] at junit.textui.TestRunner.doRun(TestRunner.java:109)
       [java] at junit.textui.TestRunner.run(TestRunner.java:72)
       [java] at junit.textui.TestRunner.run(TestRunner.java:57)
       [java] at TestLicense.main(Unknown Source)
       [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
      sorImpl.java:39)
       [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
      hodAccessorImpl.java:25)
       [java] at java.lang.reflect.Method.invoke(Method.java:585)
       [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.jav
      a:193)
       [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava
      .java:130)
       [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:705)
       [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177)
      
       [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83)
       [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
      va:275)
       [java] at org.apache.tools.ant.Task.perform(Task.java:364)
       [java] at org.apache.tools.ant.Target.execute(Target.java:341)
       [java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
       [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
      
       [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062
      )
       [java] at org.apache.tools.ant.Main.runBuild(Main.java:673)
       [java] at org.apache.tools.ant.Main.startAnt(Main.java:188)
       [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
       [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
      
       [java] Time: 0.266
      
       [java] OK (1 test)
      


      I am just starting with jboss remoting and would appreciate any help.

      jboss: 4.0.4.GA
      jdk: 1.5.0_07

      vivek



        • 1. Re: java.lang.ClassNotFoundException
          Tom Elrod Master

          The problem is that you are trying to setup your target server to also be your callback server (client.addListener(handler, locator);). If you want "push" callbacks, meaning when callback generated it will be sent at that point in time to the callback listener, will need to create a callback server within the client.

          Can reference following link to sample callback client that shows how to setup callback for both push and pull callbacks.

          http://viewcvs.labs.jboss.com/cgi-bin/viewcvs.cgi/JBossRemoting/src/main/org/jboss/remoting/samples/callback/CallbackClient.java?rev=1.7&content-type=text/vnd.viewcvs-markup

          • 2. Re: java.lang.ClassNotFoundException
            Vivek Srivastav Newbie

            Tom thanks for your reply.

            After I added a ServerCallBackHandler on the server side, the ClassNotFoundException was gone.

            I changed the code as per your suggestion, to create a Connector on the client to receive a push call. However the following code gets executed on the jboss server itself, which is where my remoting server resides as service.

            public void pingClients() {
             if (m_listeners.size() > 0) {
             Object data = "ping";
             Callback c = new Callback(data);
             Set<InvokerCallbackHandler> errorSet = new HashSet<InvokerCallbackHandler>();
             for (InvokerCallbackHandler h : m_listeners) {
             try {
             h.handleCallback(c);
             } catch (HandleCallbackException e) {
             errorSet.add(h);
             }
             }
             logger.info("Failed ping for " + errorSet.size() + " clients...");
             for (InvokerCallbackHandler h : errorSet) {
             m_listeners.remove(h);
             }
             }
             }
            


            The client never receives the ping message. Consequently once the client is added and exits without removing Listener from the server, I don't know how to remove it from the list of listeners.

            Here is my client call back handler:
            public class ClientCallbackHandler implements InvokerCallbackHandler, Serializable {
            
             public void handleCallback(Callback callback) throws HandleCallbackException {
             Object obj = callback.getParameter();
             System.out.println("The server sent: "+obj);
             }
            
            }
            


            The client is able to call invoke of the server. This works fine, however in my code I create client connector and register the client handler based on the return value from this invoke (for push callback).

             int i = (Integer) client.invoke("acquire");
             if (i >= 0) {
             String callbackLocatorURI = transport + "://" + serverName + ":" + (port + 1);
             InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI);
             setupServer(callbackLocator);
             client.addListener(handler, locator);
             }
            

            appreciate your help.
            regards,
            vivek

            • 3. Re: java.lang.ClassNotFoundException
              Vivek Srivastav Newbie

              When I remove Serializable interface from the ClientCallbackHandler then I get the following error:

              socket://localhost:6034
              Starting remoting server with locator uri of: InvokerLocator [socket://127.0.0.1:6035/]
              java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
               java.io.NotSerializableException: org.vss.service.license.client.ClientCallbackHandler
               at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:306)
               at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
               at org.jboss.remoting.Client.invoke(Client.java:525)
               at org.jboss.remoting.Client.invoke(Client.java:488)
               at org.jboss.remoting.Client.addListener(Client.java:714)
              



              • 4. Re: java.lang.ClassNotFoundException
                Vivek Srivastav Newbie

                Ignore questions. I was adding listener using server locator and not callback locator.