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

Java EE Discussion :

Injection de dépendances lorsque le jar se trouve dans un ear


Sujet :

Java EE

  1. #1
    Invité(e)
    Invité(e)
    Par défaut Injection de dépendances lorsque le jar se trouve dans un ear
    Bonjour,

    je n'arrette pas de lire qu'avec les EJB3 fini les lookup et place à l'injection de dépendance.

    Mais comment cela fonctionne t-il concrètement ?

    pour ma part j'effectue encore et toujours mes lookup en EJB3, serait ce une erreur de ma part ?

    dans cette documentation à la page 8, on nous montre un exemple d'appel de méthodes d'un EJB grâce à l'injection de dépendance.

    pour ma part, cela ne fonctionne pas et je persiste à procéder de la sorte:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
     
      Context context = new InitialContext();       
      InterfaceBean beanRemote = (InterfaceBean)context.lookup("Server/Bean/remote");
             System.out.println(beanRemote.message("Mon ejb 3 me renvoit le message"));
    quelqu'un pourrait m'éclairer ?

    merci

  2. #2
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Billets dans le blog
    1
    Par défaut
    Quel est le problème exactement avec l'annotation @EJB ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    @stateless
    public class MonEJB implements MonEJBRemote
    {
       @EJB(name="UnAutreEJBFacade/local")
       private UnAutreEJBFacadeLocal facade = null;
    ...
    }
    Tu utilises un EAR pour le déploiement ?

    A+
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Invité(e)
    Invité(e)
    Par défaut
    oui j'utilise un ear pour le déploiement.

    voila le code de mon client original et fonctionnel

    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
     
    package client_test;
     
    import java.rmi.RemoteException;
    import interfaces.InterfaceBean;
    import javax.ejb.CreateException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
     
    public class Client_test {
     
       public static void main(String[] args) throws RemoteException, CreateException {
     
    	   try {
             Context context = new InitialContext();
     
             InterfaceBean beanRemote = (InterfaceBean)context.lookup("Server/Bean/remote");
             System.out.println(beanRemote.message("Mon ejb 3 me renvoit le message"));
     
    	   } catch (NamingException e) {
             e.printStackTrace();
          }
       }
    }
    comment remplacer le lookup par l'injection ?
    désolé mais je n'y parvient pas.

    mon client est un client console externe
    il possède l'interface de mon stateless nommé Bean

    merci

    édit:
    nb: je pourrais enlever le trow CreateException c'est un reste d'un test précédent.

  4. #4
    Membre expérimenté
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    156
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 156
    Par défaut
    Si ton client est "externe", de base tu ne peux pas faire d'injection d'EJB.

  5. #5
    Invité(e)
    Invité(e)
    Par défaut
    ok !

    l'injection est donc utilisée par exemple pour ma FacadeSession
    donc plus de ServiceLocator pour le lookup

    c'est ça ?

    en revanche si j'utilise un client distant, dans ce cas la je reste "contraint" de faire le lookup

    merci

  6. #6
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Billets dans le blog
    1
    Par défaut
    Pour le client, je ne pense pas que ça puisse fonctionner, tu n'es pas dans le conteneur EJB.
    L'annotation est conçue pour référencer des EJB à l'intérieur d'EJB session.

    Pour un client (Swing par exemple), il faut passer par lookup avec un paramétrage adéquat de l'initialContext

    flûte, j'avais oublier de valider le message, du coup, j'suis grillé !
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  7. #7
    Invité(e)
    Invité(e)
    Par défaut
    merci quand même

    vaut mieux deux justifications plutôt qu'une

  8. #8
    Membre expérimenté
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    156
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 156
    Par défaut
    Citation Envoyé par amazoone Voir le message
    ok !
    l'injection est donc utilisée par exemple pour ma FacadeSession
    donc plus de ServiceLocator pour le lookup
    c'est ça ?
    oui
    en revanche si j'utilise un client distant, dans ce cas la je reste "contraint" de faire le lookup
    En fait le lookup est contraint principalement quand ton client est non managé.
    Les Composants managés par un serveur JEE5 sont à la base les Servlets, les EJB, les beans jsf etc .. A vérifier.

  9. #9
    Invité(e)
    Invité(e)
    Par défaut
    ok, je vois plus clair maintenant

    merci à vous deux, je mes en Résolu

    merci !

  10. #10
    Invité(e)
    Invité(e)
    Par défaut
    Bon et bien me revoila,

    j'ai bien compris le principe mais après application cela ne fonctionne toujours pas.

    voila mon procédé:
    Un client distant
    deux EJB3 dans un même jar (dans un ear avec un autre ejb2 qui n'interfère pas)

    le client

    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
     
    package client_test;
     
    import interfaces.InterfaceBeanFacade;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
     
    public class Client_test {
     
       public static void main(String[] args){
     
    	   try {
             Context context = new InitialContext();
     
             InterfaceBeanFacade beanRemote = (InterfaceBeanFacade)context.lookup("EJB3/BeanFacade/remote");
             System.out.println(beanRemote.message());
     
    	   } catch (NamingException e) {
             e.printStackTrace();
          }
       }
    }
    L'EJB appelé par le client de façon distante

    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
     
    package bean;
     
    import interfaces.InterfaceBeanFacade;
     
    import javax.ejb.EJB;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
     
    @Stateless(mappedName="BeanFacade")
    @Remote(InterfaceBeanFacade.class)
    public class BeanFacade implements InterfaceBeanFacade{
     
    	@EJB Bean bean;
    	public String message(){
    		return bean.message("ioc ok");
    	}
     
    }
    et l'EJB appelé par ma facade

    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
     
    package bean;
     
    import interfaces.InterfaceBean;
     
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
     
    @Stateless(mappedName="Bean")
    @Remote(InterfaceBean.class)
    public class Bean implements InterfaceBean{
     
     
    	public String message(String message){
    		return message;
    	}
     
    }
    voila l'architecture de mon code sous eclipse si ça peut aider à visualiser:



    et voila l'erreur levée:

    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
     
    Exception in thread "main" javax.ejb.EJBException: java.lang.NullPointerException
    	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:95)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
    	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:110)
    	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.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
    	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:769)
    	at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
    	at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
    	at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
    Caused by: java.lang.NullPointerException
    	at bean.BeanFacade.message(BeanFacade.java:15)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	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.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:95)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
    	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:110)
    	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.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
    	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:769)
    	at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
    	at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
    	at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
    	at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
    	at org.jboss.remoting.Client.invoke(Client.java:1634)
    	at org.jboss.remoting.Client.invoke(Client.java:548)
    	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:67)
    	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:74)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
    	at $Proxy0.message(Unknown Source)
    	at client_test.Client_test.main(Client_test.java:16)
    	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:67)
    	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:74)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
    	at $Proxy0.message(Unknown Source)
    	at client_test.Client_test.main(Client_test.java:16)
    si quelqu'un pouvait m'aider à trouver l'étape que j'ai loupé ?

    merci beaucoup


    EDIT:

    je comprend plus rien la ^^
    d'après le message d'errerur, il semblerait qu'il ne trouve pas la classe.
    Je ne cré pas d'instance de mon bean Bean car l'injection de dépendance est censé le faire pour moi non ?

    donc dans le doute j'ai fais un test, et j'ai instancié ma classe Bean de la sorte

    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
     
    package bean;
     
    import interfaces.InterfaceBeanFacade;
     
    import javax.ejb.EJB;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
     
    @Stateless(mappedName="BeanFacade")
    @Remote(InterfaceBeanFacade.class)
    public class BeanFacade implements InterfaceBeanFacade{
     
    	@EJB Bean bean = new Bean();
    	public String message(){
    		return bean.message("ioc ok");
    	}
     
    }
    résultat: ba ça fonctionne normal me direz vous! et justement cela perd tout son intéret de faire ainsi ??

    le @EJB Bean bean devrait suffir à lui seul pour récupérer une instance avec IoC normalement

    d'ou peu venir l'erreur alors ?
    car cela veut dire que le @EJB Bean bean ne fait pas son travail dans mon application

    une idée ?

    merci
    Dernière modification par Invité(e) ; 12/06/2008 à 17h43.

  11. #11
    Invité(e)
    Invité(e)
    Par défaut
    Bon étant donné que mon EJB3 se trouve dans un ear je me suis dit que j'allais dans un premier temps le mettre hors de cet ear (c'est on jamais si le problème venait de la)

    et au moment du déploiement voila l'erreur générée:
    java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container BeanFacade: reference class: bean.Bean ejbLink: not used by any EJBs


    quelqu'un comprend ceci ??
    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
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
     
    7:59:28,188 WARN  [ServiceController] Problem starting service jboss.j2ee:jar=EJB3.jar,name=BeanFacade,service=EJB3
    java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container BeanFacade: reference class: bean.Bean ejbLink:  not used by any EJBs
    	at org.jboss.injection.EjbEncInjector.inject(EjbEncInjector.java:88)
    	at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:566)
    	at org.jboss.ejb3.SessionContainer.start(SessionContainer.java:154)
    	at org.jboss.ejb3.stateless.StatelessContainer.start(StatelessContainer.java:102)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:103)
    	at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    	at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    	at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    	at $Proxy0.start(Unknown Source)
    	at org.jboss.system.ServiceController.start(ServiceController.java:417)
    	at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    	at $Proxy48.start(Unknown Source)
    	at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:120)
    	at org.jboss.ejb3.Ejb3Deployment.registerEJBContainer(Ejb3Deployment.java:301)
    	at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:362)
    	at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
    	at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    	at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    	at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    	at $Proxy0.start(Unknown Source)
    	at org.jboss.system.ServiceController.start(ServiceController.java:417)
    	at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    	at $Proxy32.start(Unknown Source)
    	at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    	at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    	at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    	at $Proxy33.start(Unknown Source)
    	at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    	at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    	at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    	at $Proxy10.deploy(Unknown Source)
    	at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
    	at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
    	at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
    	at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
    	at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    	at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    	at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    	at $Proxy0.start(Unknown Source)
    	at org.jboss.system.ServiceController.start(ServiceController.java:417)
    	at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    	at $Proxy4.start(Unknown Source)
    	at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
    	at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    	at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    	at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    	at $Proxy5.deploy(Unknown Source)
    	at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    	at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    	at org.jboss.Main.boot(Main.java:200)
    	at org.jboss.Main$1.run(Main.java:508)
    	at java.lang.Thread.run(Thread.java:595)
    17:59:28,193 INFO  [EJB3Deployer] Deployed: file:/C:/EclipseWorkspace-vmargs/AtanorServerPlatform/ws/servers/JBoss-4.2.2GA/server/default/deploy/EJB3.jar
    17:59:28,234 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
    17:59:28,411 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
     
    --- MBeans waiting for other MBeans ---
    ObjectName: jboss.j2ee:jar=EJB3.jar,name=BeanFacade,service=EJB3
      State: FAILED
      Reason: java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container BeanFacade: reference class: bean.Bean ejbLink:  not used by any EJBs
     
    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
    ObjectName: jboss.j2ee:jar=EJB3.jar,name=BeanFacade,service=EJB3
      State: FAILED
      Reason: java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container BeanFacade: reference class: bean.Bean ejbLink:  not used by any EJBs
    merci

  12. #12
    Invité(e)
    Invité(e)
    Par défaut
    Bonjour,

    un doute subsiste,

    avec @EJB c'est l'EJB que l'on récupère ou son interface ?
    car avec l'interface tout fonctionne mais pas avec le Session bean.

    d'après la spécification EJB3 on peut récupérer une interface

    Citation Envoyé par spécification EJB3
    Injection of EJB References
    The Bean Provider uses the EJB annotation to annotate a field or setter property method of the bean
    class as a target for the injection of an EJB reference. The reference may be to a session bean’s business
    interface or to the local home interface or remote home interface of a session bean or entity bean.
    mais peut on récupérer un bean directement sans passer par l'interface ?

    merci

  13. #13
    Membre expérimenté
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    156
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 156
    Par défaut
    Citation Envoyé par amazoone Voir le message
    mais peut on récupérer un bean directement sans passer par l'interface ?

    merci
    Non. C'est le principe même des EJB.
    Le client ne manipule pas l'implémentation de l'EJB mais uniquement les interfaces.
    Cela permet au container EJB de gérer les aspects sécurité, transaction etc ..

  14. #14
    Invité(e)
    Invité(e)
    Par défaut
    ok merci pour la précision

    et en ce qui concerne mon problème d'injection d'EJB dans l'EAR quelqu'un à une idée ?

  15. #15
    Invité(e)
    Invité(e)
    Par défaut
    Bonjour,

    après différentes tentatives ainsi que des recherches je ne parviens toujours pas à utiliser l'injection de dépendance avec les EJB3 lorsque mon JAR se trouve dans un EAR

    personne n'utilise ce procédé ?

    need help !

Discussions similaires

  1. Fichier ".jar" pas trouvé -- dans une "User library"
    Par chat_roux dans le forum Eclipse Java
    Réponses: 4
    Dernier message: 11/10/2008, 22h16
  2. .jars non trouvés avec Tomcat
    Par Invité dans le forum Eclipse Java
    Réponses: 3
    Dernier message: 03/05/2007, 09h26
  3. Dépendance entre jar situés au meme niveau dans un EAR
    Par florentB dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 10/04/2007, 17h09
  4. [Integration] [EasyMock] Injection de dépendance à l'éxécution
    Par frangin2003 dans le forum Spring
    Réponses: 2
    Dernier message: 06/03/2007, 11h06
  5. Spring + TagSupport et injection de dépendance
    Par worldchampion57 dans le forum Spring Web
    Réponses: 2
    Dernier message: 26/02/2007, 09h01

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