Exception in thread "main" java.lang.NoSuchMethodError

yoarf Messages postés 215 Date d'inscription jeudi 19 décembre 2002 Statut Membre Dernière intervention 19 février 2009 - 7 mai 2007 à 20:39
scaryman Messages postés 492 Date d'inscription vendredi 30 janvier 2004 Statut Membre Dernière intervention 16 mai 2007 - 8 mai 2007 à 10:30
Bonjour,

J'ai l'erreur suivante : Exception in thread "main" java.lang.NoSuchMethodError: hw.compteurHome.create(I)Lhw/compteur;
    at hw.compteurClient.main(compteurClient.java:36)

Sur le code suivant :
// compteurClient.java
// mini Client for accessing bean compteur

package hw;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

/**
 *
 */
public class compteurClient {

    static Context ctx = null;
    static compteurHome home = null;

    public static void main(String[] arg) {
       
    // Get InitialContext
    try {
        ctx = getInitialContext();
    } catch (NamingException e) {
        e.printStackTrace();
        System.exit(2);
    }

    // Lookup bean home
    String bName = "compteurHome";
    try {
        home = (compteurHome) PortableRemoteObject.narrow(ctx.lookup(bName), compteurHome.class);
        compteur bean1 = home.create();
        compteur bean2 = home.create(10);
       
        bean1.incremente();
        bean1.incremente();
        bean2.incremente();
        bean2.incremente();
       
        System.out.println(bean1.getValeur());
        System.out.println(bean2.getValeur());
       
    } catch(Exception e) {
        e.printStackTrace();
        System.exit(2);
    }
    }
   
    /**
     * Using a Properties object will work on JDK 1.1.x and Java2
     * clients
     */
    static private Context getInitialContext() throws NamingException {
      String url = "rmi://localhost:1099";
     
      try {
        // Get an InitialContext
        Properties h = new Properties();
        h.put(Context.INITIAL_CONTEXT_FACTORY,
          "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");
        h.put(Context.PROVIDER_URL, url);
        return new InitialContext(h);
      } catch (NamingException ne) {
          ne.printStackTrace();
        throw ne;
      }
    }
   
}

Merci beaucoup d'avance.

Y.C

1 réponse

scaryman Messages postés 492 Date d'inscription vendredi 30 janvier 2004 Statut Membre Dernière intervention 16 mai 2007 12
8 mai 2007 à 10:30
Salut.
Il y a une méthode dans ta classe compteurHome qui n'existe pas et que tu essaies pourtant d'accéder.
Je pencherais pour la méthode create(int i) vu qu'il accepte la méthode create().

A+
0
Rejoignez-nous