learner
learner

Reputation: 757

java.lang.AbstractMethodError in simple Java RMI example

i m beginning Java RMI with a simple example. the actual example works fine (from roseindia) but i have extended it a little and i get error. The file for remote interface is as follows:-

import java.rmi.*;

public interface RemoteInterface extends Remote
{
 public int add(int x,int y)throws Exception;  //original line
 public int sub(int x, int y)throws Exception; //added later by me
}

Now the code snippet for the Client file that generates error is :-

b.addActionListener(new ActionListener() {  // b is a JButton
public void actionPerformed(ActionEvent evt) {
int a = Integer.parseInt(t1.getText());     //t1 and t2 are TextField
int b = Integer.parseInt(t2.getText());
try {
int r  = s.add(a,b); 

 rs.setText("Sum of two no.s=" + r);       //rs is a Label
} catch (Exception epx) {
}
}
});

it works fine. but when i add the following for another button

  b2.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt1) {
  int a1 = Integer.parseInt(t1.getText());
  int b2 = Integer.parseInt(t2.getText());
  try {
        int r2 = s.sub(a1, b2);
  rs.setText("Subtraction of two no.s =" + r2);
    } catch (Exception epx) {
     }
   }
    });

i get following error

C:\Program Files\Java\jdk1.6.0_14\bin>java Client
Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: ServerImpl
ements_Stub.sub(II)I
    at Client$2.actionPerformed(Client.java:65)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
95)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6263)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6028)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4630)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574
   )
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)

    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
    ad.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
  java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
  ad.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Just a hint of problem would be too helpful. thanks in advance.

Upvotes: 0

Views: 2344

Answers (1)

user207421
user207421

Reputation: 310840

You've changed something without recompiling all its dependencies: in this case you haven't regenerated the stub. Recompile everything and retest.

Upvotes: 3

Related Questions