IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Développement Web en Java Discussion :

Appel du même bean par plusieurs clients


Sujet :

Développement Web en Java

  1. #1
    Futur Membre du Club
    Inscrit en
    Août 2009
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Août 2009
    Messages : 10
    Points : 8
    Points
    8
    Par défaut Appel du même bean par plusieurs clients
    Bonjour,
    c'est la troisième fois que je poste une question dans ce forum et j'espère maintenant que quelqu'un me répond
    je développe en ejb3.0 une application et je désire créer plusieurs clients qui appellent le même bean qui renvoie un vecteur de données différentes à chaque client.
    J'ai utilisé lookup pour invoquer le serveur puis j'ai appelé avec différents paramètres la même méthode mais une erreur se produit .
    Ma question est comment instancier plusieurs beans dans la même classe client
    J'attends vos réponse

  2. #2
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Citation Envoyé par mouna- Voir le message
    mais une erreur se produit .
    Et bien sûr, on est censé deviner de nous même

    quel est le code
    quelle est l'erreur
    quelle est la nature du bean

  3. #3
    Futur Membre du Club
    Inscrit en
    Août 2009
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Août 2009
    Messages : 10
    Points : 8
    Points
    8
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    package test.client;
    
    import java.util.Properties;
    import java.util.Vector;
    
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import proje.j2.bean.*;
    
    public class cl {
      
     
      
         public static void main(String[]args) {
        Context context=null;
        int i,j,chvision,seuil,posx,posy,k;
        Grille  beanRemote;
        Thread runner=null;
        Obstacle  beanRem;
        
        Vector vois,vois1;
        Properties env = new Properties();
        env.setProperty( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
        env.setProperty( "java.naming.provider.url", "127.0.0.1:1099" );
         env.setProperty( "java.naming.factory.url.pkgs", "org.jboss.naming" );
          
            try{
                vois =new Vector();
                vois1 =new Vector();
    
                    context = new InitialContext(env);   
                   beanRemote = (Grille)context.lookup("GrilleBean/remote");
                  beanRem = (Obstacle)context.lookup("ObstacleBean/remote");
                   beanRemote.setGrilleBean();
                   beanRem.addObstacle(2,2,4,4,10,15,0);
                   beanRem.newVect(); 
                 vois=(Vector)beanRem.geTrace();
                 System.out.print("client1"+"\n");
                 for(int kk=0;kk!=vois.size();kk++)
                 System.out.print(vois.elementAt(kk)+" ");
        
                 beanRem.addObstacle(3,3,5,5,10,15,0);
                 beanRem.newVect(); 
                 vois1=(Vector)beanRem.geTrace();
                 System.out.print("client2"+"\n");
                 for(int kk=0;kk!=vois1.size();kk++)
                 System.out.print(vois1.elementAt(kk)+" ");
                
                
                  }
          
            catch (NamingException e) {
               //  e.printStackTrace();
              }
    
     
           }
     }
    je débute en ejb donc excusez moi s'il s'agit d'une faute banale

    voilà l'erreur qui se produit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    log4j:WARN No appenders could be found for logger (org.jboss.remoting.transport.socket.MicroSocketClientInvoker).
    log4j:WARN Please initialize the log4j system properly.
    client1
    2 2 2 3 3 4 4 4 Exception in thread "main" javax.ejb.EJBException: java.lang.ArrayIndexOutOfBoundsException: -2
    	at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
    	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
    	at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
    	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.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:333)
    	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.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:135)
    	at $Proxy2.addObstacle(Unknown Source)
    	at test.client.cl.main(cl.java:43)
    	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.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:135)
    	at $Proxy2.addObstacle(Unknown Source)
    	at test.client.cl.main(cl.java:43)
    Caused by: java.lang.ArrayIndexOutOfBoundsException: -2
    	at java.util.Vector.elementAt(Unknown Source)
    	at proje.j2.bean.ObstacleBean.newVect(ObstacleBean.java:205)
    	at proje.j2.bean.ObstacleBean.setxsety(ObstacleBean.java:73)
    	at proje.j2.bean.ObstacleBean.addObstacle(ObstacleBean.java:38)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
    	at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
    	at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
    	at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
    	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.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:333)
    	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)

  4. #4
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Caused by: java.lang.ArrayIndexOutOfBoundsException: -2
    at java.util.Vector.elementAt(Unknown Source)
    at proje.j2.bean.ObstacleBean.newVect(ObstacleBean.java:205)
    L'erreur se trouve dans votre méthode newVect, vous essayez d'accéder à l'index -2 d'un vecteur.

  5. #5
    Futur Membre du Club
    Inscrit en
    Août 2009
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Août 2009
    Messages : 10
    Points : 8
    Points
    8
    Par défaut

    oui je vois bien mais ceci ne se produit que si j'appelle de nouveau le bean
    càd je dois trouver une autre méthode pour appeler plusieurs fois le même bean

  6. #6
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    non vous devez corriger le code de votre bean pour éviter qu'il fasse n'importe quoi.

  7. #7
    Futur Membre du Club
    Inscrit en
    Août 2009
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Août 2009
    Messages : 10
    Points : 8
    Points
    8
    Par défaut
    MERCI bien effectivement j'ai commis une faute banaaaaaaaale dans le code

Discussions similaires

  1. Réponses: 5
    Dernier message: 21/12/2007, 08h24
  2. Appel d'un webservice par un client
    Par ilhamita dans le forum Services Web
    Réponses: 0
    Dernier message: 20/11/2007, 11h53
  3. Variable accessible par plusieurs clients
    Par mezoo dans le forum Servlets/JSP
    Réponses: 3
    Dernier message: 06/10/2006, 10h08
  4. Réponses: 6
    Dernier message: 11/09/2006, 12h58
  5. Réponses: 9
    Dernier message: 17/04/2004, 16h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo