Appel de méthodes

tahjava Messages postés 2 Date d'inscription lundi 12 mai 2008 Statut Membre Dernière intervention 7 avril 2009 - 7 avril 2009 à 12:59
tahjava Messages postés 2 Date d'inscription lundi 12 mai 2008 Statut Membre Dernière intervention 7 avril 2009 - 7 avril 2009 à 18:01
Souvent dans un programme donné on trouve des erreurs de ce genre lors de l'appel d'une méthode donnée, voici le code source et l'erreur générée:
package demo;

import java.net.URISyntaxException;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.jvoicexml.JVoiceXml;
import org.jvoicexml.RemoteClient;
import org.jvoicexml.Session;
import org.jvoicexml.event.ErrorEvent;

public class Demo1 {

    public static void main(String[] args) throws ErrorEvent {
       
        JVoiceXml jvxml = null ;
        try {
            Context context = new InitialContext();
            //rmi://localhost:1099/
            jvxml = (JVoiceXml) context.lookup("rmi://localhost:1099/JVoiceXml");
          
            final Session session= jvxml.createSession(null);
            final java.net.URI ur;
            ur = new java.net.URI("http://localhost:8080/demo1/hello.vxml");
            session.call(ur);
            session.waitSessionEnd();
               ((Context) session).close();
           
        } catch (javax.naming.NamingException ne ) {
         ne.printStackTrace();
         System.exit(-1);
        } catch (URISyntaxException e ) {
            e.printStackTrace ( ) ;
            System.exit(-1);
        } catch (org.jvoicexml.event.JVoiceXMLEvent be ) {
            be.printStackTrace ( ) ;
            System.exit(-1);
        }
       
       
    }
   
}
Voici l'erreur (Demo1.java:22 concerne la ligne soulignée) dans le code :

java.lang.NullPointerException
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:93)
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:103)
    at org.jvoicexml.client.jndi.AbstractStub.getSkeleton(AbstractStub.java:157)
    at org.jvoicexml.client.jndi.JVoiceXmlStub.createSession(JVoiceXmlStub.java:113)
    at demo.Demo1.main(Demo1.java:22)
Exception in thread "main" java.lang.NullPointerException
    at org.jvoicexml.client.jndi.JVoiceXmlStub.createSession(JVoiceXmlStub.java:118)
    at demo.Demo1.main(Demo1.java:22)

Question: je me demande comment peut on résoudre ce genre de problème?
MERCI d'AVANCE.

2 réponses

super_toinou Messages postés 764 Date d'inscription mardi 25 mai 2004 Statut Membre Dernière intervention 8 mars 2011 6
7 avril 2009 à 17:06
Hello,

faudrait pas faire un truc du genre

   final Session session= jvxml.createSession(jvxml );

en gros tu demandes d'avoir une session sur rien, ca me parait normal que ça t envoie bouler.
C est quoi l'argument de la fonction createSession(xxxx) ??

++
0
tahjava Messages postés 2 Date d'inscription lundi 12 mai 2008 Statut Membre Dernière intervention 7 avril 2009
7 avril 2009 à 18:01
Salut,
l'argument de la fonction createSession() est  RemoteClient.
En fait je veux transformer du texte en voie en utilisant l'api jvoicexml, mais le programme ce bloque au niveau de cette fonction createSession().
Merci pour votre aide.
0
Rejoignez-nous