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

Spring Java Discussion :

[Spring MVC] Injection EJB3 dans le controleur


Sujet :

Spring Java

  1. #1
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut [Spring MVC] Injection EJB3 dans le controleur
    Bonjour,

    Pour un projet d'une application WEB j'utilise Spring MVC seulement en tant que framework de presentation (dans un WAR).Je ne me sers pas de Spring pour le developpement de partie business.

    Le reste de mon application est donc composée de projets EJB3 qui sont les différents services (facades) de mon application.

    Ma question est simple : peut ont injecter ces services (EJB3) dans un contrôleur Spring MVC par exemple avec une annotation ?

    Si oui par quel moyen ? Je n'ai pas trouver mon bonheur via google.
    Merci d'avance pour votre aide.

  2. #2
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut
    Par exemple j'aimerais faire quelque chose de ce genre :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    @Controller
    public class MonControler {
    
    @EJB
    private ServiceDao monservice
    
    @RequestMapping("/execute")
    public String maMethode (){
    
    
    monservice.maMethode(); return "maVue";
    }
    Merci de votre aide !

  3. #3
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Oui bien sur, si ton EJB3 est bien défini (interface et classe concrete) tu peux très bien faire appel comme tu l'as mis en rouge, c'est ce que je fais dans mon projet et ca marche bien. c'est quoi ton souci au fait? ca bloque à quel niveau?

  4. #4
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut
    Tout d'abord merci pour ton aide.
    Mon application est packagée dans un EAR (= EJB3 + WAR)

    Je travaille avec JBOSS 4.2.3 et Spring 3.03

    J'ai été obligé de faire la chose suivante pour que ca marche, dans mon app-config.xml (conf spring)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
      <bean    class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
        <property name="alwaysUseJndiLookup" value="true" />
      </bean>
    et dans mon controller

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    @Controller
    @RequestMapping("/service")
    
    public class UserController extends BaseController {
    
    	@EJB(name = "MonEAR/MonServiceDAO/local") 
    	MonServiceDAO monserviceDAO;.....
    .
    sinon quand l'application est déployée il ne trouve pas le bean...

    Peux tu me donner ta solution (configuration) pour que je puisse me passer de ces noms a rallonge

    Merci de ton aide

  5. #5
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Peux tu me montrer de la classe et l'interface qui va avec? surtout les entetes.

  6. #6
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut
    Voici l'entête de l'interface

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    @Local
    public interface MonServiceDAO  {
    ...
    }
    l'implémentation :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    @Stateless(mappedName = "MonServiceDAO", name = "MonServiceDAO")
    public class ServiceDAOBean implements MonServiceDAO {
    Merci sincèrement de ton aide.

  7. #7
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut
    @DevServlet une idée ? si tu as un petit projet qui marche ou un exemple de fichiers de conf (application, spring etc...) je suis preneur et je me débrouillerai.

    Ça m'aiderai beaucoup pour avancer merci !

  8. #8
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Moi je mets un sur l'interface, et simplement un sur mon ejb, ensuite lors de l'appel je mets un @EJB comme toi et ca marche bien, t'as quoi erreur en faisant ainsi?

  9. #9
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut
    si je fais comme toi et en enlevant mon paramétrage dans CommonAnnotationBeanPostProcessor (voir plus haut)

    j'obtiens :
    (ici le service est UserDAO et le controller est UserController)

    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
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    09:23:14,340 ERROR [DispatcherServlet] Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.demo.common.dao.UserDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.ejb.EJB(mappedName=, beanInterface=class java.lang.Object, beanName=, description=, name=)}
    	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1064)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4071)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4375)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
    	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:592)
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
    	at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
    	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:592)
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
    	at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
    	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    	at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
    	at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
    	at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
    	at org.jboss.web.WebModule.startModule(WebModule.java:83)
    	at org.jboss.web.WebModule.startService(WebModule.java:61)
    	at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    	at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    	at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:592)
    	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.GeneratedMethodAccessor9.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:592)
    	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 $Proxy44.start(Unknown Source)
    	at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
    	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:592)
    	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.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
    	at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
    	at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
    	at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
    	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 $Proxy45.start(Unknown Source)
    	at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    	at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
    	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    	at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:592)
    	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 $Proxy9.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.GeneratedMethodAccessor3.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:592)
    	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.GeneratedMethodAccessor9.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:592)
    	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:304)
    	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:592)
    	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)
    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.demo.common.dao.UserDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.ejb.EJB(mappedName=, beanInterface=class java.lang.Object, beanName=, description=, name=)}
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:914)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:783)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
    	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:431)
    	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:409)
    	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$EjbRefElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:690)
    	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:147)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:297)
    	... 154 more

  10. #10
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Ok essaie un peu ca alors :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Context initialContext = new InitialContext();
        InterfaceDeTonEJB facadeBean= (InterfaceDeTonEJB) initialContext.lookup("nom_mapped_de_ton_ejb");

  11. #11
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut
    C'est la méthode que j'utilisais avant d'essayer l'injection avec @EJB.
    par contre je suis toujours obligé de préciser le nom de l'EAR et l'interface local sinon il ne trouve pas l'EJB !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    initialContext.lookup(""NomEar/"+nom_mapped_de_ton_ejb+"/local");
    ou
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    initialContext.lookup(""NomEar/"+nom_ejb+"/local");
    Mais j'aimerais le faire simplement comme tu le fais sans avoir a préciser tout ça.

  12. #12
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    non t'es pas obligé normalement, t'as essayé en remote? juste le mappedName suffit.

  13. #13
    Membre averti Avatar de ZeRevo
    Inscrit en
    Avril 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations forums :
    Inscription : Avril 2007
    Messages : 302
    Points : 343
    Points
    343
    Par défaut
    Tu utilises tomcat, jboss ? quelle version?

  14. #14
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut
    @ZeRevo
    Je travaille avec JBOSS 4.2.3 et Spring 3.03 (précisé dans le deuxième post)

    @DevServlet
    Oui j'ai essayé avec @Remote et l'ejb n'est pas trouvé non plus

  15. #15
    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
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par DevServlet Voir le message
    non t'es pas obligé normalement, t'as essayé en remote? juste le mappedName suffit.
    Non, avec la version 4.2.x, il y a une différence lorsqu'on installe un EAR ou un WAR/JAR.
    Il se trouve qu'avec l'EAR, il faut mettre le nom de ce dernier au niveau du lookup et pas dans les autres cas, c'est super pénible...
    Il y a certainement un moyen de contourner le problème mais à l'époque, je n'avais pas trouvé.
    Il me semble qu'ils ont corrigé ça à partir de la v5, à voir...

  16. #16
    Membre à l'essai
    Profil pro
    crut
    Inscrit en
    Mars 2003
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : crut
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mars 2003
    Messages : 28
    Points : 22
    Points
    22
    Par défaut
    Effectivement avec un JBoss 5.0 y a du mieux

    Config : Spring 3.03 + JBOSS 5.0 + JDK 1.5


    1- Dans mon app-config.xml (spring) je dois laisser :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <bean    class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
        <property name="alwaysUseJndiLookup" value="true" />
    </bean>

    2- L'interface de mon EJB est annotée avec @Local
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    @Local
    public interface UserDAO  {...}
    3- Mon EJB est annoté seulement avec @Stateless
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    @Stateless
    public class UserDAOBean implements UserDAO {...}
    l'appel dans mon contrôleur SPRING MVC se fait avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    @Controller
     
    public class UserController  {
    @EJB(name = "UserDAOBean")   //
    UserDAO userDAO;
    ...
    }
    Je ne vois pas comment faire mieux .... et encore c'est avec JBOSS 5.0...
    Quelle est la configuration la plus simple de spring que vous avez utilisé pour faire marcher ca directement avec seulement 2 annotations ?

  17. #17
    Candidat au Club
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 2
    Points : 2
    Points
    2
    Par défaut Intégration EJB3 avec Spring MVC3
    Bonjour à tous,

    Je ressuscite ce topic à cause d'un problème d'injection d'EJB dans un controller Spring MVC 3.

    J'ai suivi la dernière réponse de NaBuCO mais j'ai toujours un souci d'injection.

    Information relative à l'environnement :
    1. JDK1.7
    2. JBOSS 7.1.1
    3. Maven 3.0.4
    4. Packaging dans un unique war



    Fichier web.xml dans src/main/webapp/WEB-INF
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    	version="2.4">
    	<display-name>SpringDemo</display-name>
    	<description>SpringDemo</description>
     
     
    	<welcome-file-list>
    		<welcome-file>index.jsp</welcome-file>
    	</welcome-file-list>
     
     
    	<servlet>
    		<servlet-name>dispatcher</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
    		</init-param>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>dispatcher</servlet-name>
    		<url-pattern>/</url-pattern>
    	</servlet-mapping>
     
     
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    </web-app>
    Fichier dispatcher-servlet.xml dans src/main/webapp/WEB-INF
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jee="http://www.springframework.org/schema/jee"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
     
    	<context:annotation-config />
     
    	<!-- packages pour les controllers -->
    	<context:component-scan base-package="controller" />
     
    	<bean
    		class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
    		<property name="alwaysUseJndiLookup" value="true" />
    	</bean>
     
    	<!-- support JSR303 annotation if JSR 303 validation present on classpath -->
    	<mvc:annotation-driven />
     
    	<!-- mapping url -->
    	<bean
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix">
    			<value>/WEB-INF/views/</value>
    		</property>
    		<property name="suffix">
    			<value>.jsp</value>
    		</property>
    	</bean>
     
    	<bean
    		class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
    		<property name="alwaysUseJndiLookup" value="true" />
    	</bean>
     
    </beans>
    Fichier persistence.xml dans src/main/resources
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
       version="1.0">
     
       <persistence-unit name="persistenceUnit" transaction-type="JTA">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>java:jboss/MySqlDS</jta-data-source>
          <properties>
              <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
               <property name="hibernate.show_sql" value="true"/>
          </properties>
       </persistence-unit>
    </persistence>
    Mon interface de DAO
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    package dao;
     
    import javax.ejb.Local;
    import domaine.User;
     
    @Local
    public interface IUserDAO {
     
    	public String getNameById(final int id);
     
    	public void createUser(String name, String firstname, String email);
     
    	public void updateUser(User user);
    }
    Son implémentation
    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
    package dao.implement;
     
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import dao.IUserDAO;
    import domaine.User;
     
     
    @Stateless
    public class UserDAO implements IUserDAO{
     
    	@PersistenceContext(name="persistenceUnit")
    	private EntityManager em;
     
    	public UserDAO(){
    		super();
    	}
     
             .....
    }

    Mon controller
    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
    package controller;
     
    import javax.ejb.EJB;
    import javax.validation.Valid;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.validation.BindingResult;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import dao.IUserDAO;
    import viewmodel.User;
     
    @Controller
    public class WelcomeController {
     
    	@EJB(name="UserDAO")
    	private IUserDAO userDAO;
     
    	@RequestMapping(value="/welcome",method=RequestMethod.GET)
    	public String welcome(Model model) {
     
    	}
     
    	@RequestMapping(value="/addContact",method=RequestMethod.GET)
    	public String addContact(@Valid User user, BindingResult result) {
     
    	}
     
    }
    Les logs de JBoss durant le déploiement de l'application
    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
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    15:36:56,847 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session [java:jboss/mail/Default]
    15:36:56,937 INFO  [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
    15:36:57,085 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services - Stack CXF Server 4.0.2.GA
    15:36:57,124 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory C:\Users\Administrateur\Downloads\jboss-as-7.1.1.Final\standalone\deployments
    15:36:57,197 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /0.0.0.0:4447
    15:36:57,211 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /127.0.0.1:9999
    15:36:57,327 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Démarrage de Coyote HTTP/1.1 sur http--0.0.0.0-8080
    15:36:57,418 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/MySqlDS]
    15:36:57,437 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
    15:36:57,490 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "monsite.war"
    15:36:58,449 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011401: Read persistence.xml for persistenceUnit
    15:36:58,645 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named UserDAO in deployment unit deployment "monsite.war" are as follows:
     
    	java:global/monsite/UserDAO!dao.IUserDAO
    	java:app/monsite/UserDAO!dao.IUserDAO
    	java:module/UserDAO!dao.IUserDAO
    	java:global/monsite/UserDAO
    	java:app/monsite/UserDAO
    	java:module/UserDAO
     
    15:36:58,793 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011402: Starting Persistence Unit Service 'monsite.war#persistenceUnit'
    15:36:58,897 INFO  [org.hibernate.annotations.common.Version] (MSC service thread 1-1) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
    15:36:58,910 INFO  [org.hibernate.Version] (MSC service thread 1-1) HHH000412: Hibernate Core {4.0.1.Final}
    15:36:58,914 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-1) HHH000206: hibernate.properties not found
    15:36:58,918 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-1) HHH000021: Bytecode provider name : javassist
    15:36:58,935 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-1) HHH000204: Processing PersistenceUnitInfo [
    	name: persistenceUnit
    	...]
    15:36:59,046 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-1) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
    15:36:59,302 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-1) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
    15:36:59,322 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-1) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
    15:36:59,331 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-1) HHH000397: Using ASTQueryTranslatorFactory
    15:36:59,367 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-1) Hibernate Validator 4.2.0.Final
    15:36:59,519 INFO  [org.hibernate.tuple.PojoInstantiator] (MSC service thread 1-1) HHH000182: No default (no-argument) constructor for class: domaine.User (class must be instantiated by Interceptor)
    15:36:59,584 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-1) HHH000227: Running hbm2ddl schema export
    15:36:59,592 INFO  [stdout] (MSC service thread 1-1) Hibernate: drop table if exists User
     
    15:36:59,598 INFO  [stdout] (MSC service thread 1-1) Hibernate: drop table if exists hibernate_sequence
     
    15:36:59,602 INFO  [stdout] (MSC service thread 1-1) Hibernate: create table User (user_id integer not null, email varchar(255), firstName varchar(255), name varchar(255), primary key (user_id))
     
    15:36:59,612 INFO  [stdout] (MSC service thread 1-1) Hibernate: create table hibernate_sequence ( next_val bigint )
     
    15:36:59,620 INFO  [stdout] (MSC service thread 1-1) Hibernate: insert into hibernate_sequence values ( 1 )
     
    15:36:59,629 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-1) HHH000230: Schema export complete
    15:36:59,683 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/monsite]] (MSC service thread 1-1) No Spring WebApplicationInitializer types detected on classpath
    15:36:59,700 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/monsite]] (MSC service thread 1-1) Initializing Spring root WebApplicationContext
    15:36:59,702 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-1) Root WebApplicationContext: initialization started
    15:36:59,747 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-1) Refreshing Root WebApplicationContext: startup date [Sun Mar 03 15:36:59 CET 2013]; root of context hierarchy
    15:36:59,780 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-1) Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    15:36:59,783 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-1) Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:527) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:441) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
    	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
    Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    	at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:140) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	... 20 more
     
    15:36:59,827 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/monsite]] (MSC service thread 1-1) Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:527) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:441) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
    	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
    Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    	at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:140) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	... 20 more
     
    15:36:59,915 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-1) Error listenerStart
    15:36:59,916 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-1) Erreur de démarrage du contexte [/monsite] suite aux erreurs précédentes
    15:36:59,934 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/monsite]] (MSC service thread 1-1) Closing Spring root WebApplicationContext
    15:36:59,935 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-1) Closing Root WebApplicationContext: startup date [Sun Mar 03 15:36:59 CET 2013]; root of context hierarchy
    15:36:59,941 WARN  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-1) Exception thrown from ApplicationListener handling ContextClosedEvent: java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Sun Mar 03 15:36:59 CET 2013]; root of context hierarchy
    	at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:337) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1030) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:993) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:548) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3489) [jbossweb-7.0.13.Final.jar:]
    	at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3999) [jbossweb-7.0.13.Final.jar:]
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3917) [jbossweb-7.0.13.Final.jar:]
    	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
    	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
     
    15:36:59,965 WARN  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-1) Exception thrown from LifecycleProcessor on context close: java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Sun Mar 03 15:36:59 CET 2013]; root of context hierarchy
    	at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:350) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1038) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:993) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:548) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3489) [jbossweb-7.0.13.Final.jar:]
    	at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3999) [jbossweb-7.0.13.Final.jar:]
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3917) [jbossweb-7.0.13.Final.jar:]
    	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
    	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
     
    15:36:59,987 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/monsite]] (MSC service thread 1-1) Exception lors de l'envoi de l'évènement contexte détruit (context destroyed) à l'instance de classe d'écoute org.springframework.web.context.ContextLoaderListener: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1071) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1045) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:993) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:548) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142) [spring-web-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3489) [jbossweb-7.0.13.Final.jar:]
    	at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3999) [jbossweb-7.0.13.Final.jar:]
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3917) [jbossweb-7.0.13.Final.jar:]
    	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
    	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
     
    15:37:00,027 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.web.deployment.default-host./monsite: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./monsite: JBAS018040: Failed to start context
    	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
    	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
     
    15:37:00,042 INFO  [org.jboss.as] (MSC service thread 1-1) JBAS015951: Admin console listening on http://127.0.0.1:9990
    15:37:00,043 ERROR [org.jboss.as] (MSC service thread 1-1) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 5495ms - Started 245 of 325 services (2 services failed or missing dependencies, 76 services are passive or on-demand)
    15:37:00,280 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "monsite.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./monsite" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./monsite: JBAS018040: Failed to start context"}}
    15:37:00,283 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011403: Stopping Persistence Unit Service 'monsite.war#persistenceUnit'
    15:37:00,293 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-4) HHH000227: Running hbm2ddl schema export
    15:37:00,299 INFO  [stdout] (MSC service thread 1-4) Hibernate: drop table if exists User
     
    15:37:00,306 INFO  [stdout] (MSC service thread 1-4) Hibernate: drop table if exists hibernate_sequence
     
    15:37:00,311 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-4) HHH000230: Schema export complete
    15:37:00,353 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment monsite.war in 103ms
    15:37:00,355 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
    JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host./monsite: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./monsite: JBAS018040: Failed to start context
     
    15:37:00,362 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./monsite" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./monsite: JBAS018040: Failed to start context"}}}}
    Ai-je oublié un fichier de config ou ai-je fait une configuration hasardeuse quelque part ?

    J'ai fait la même chose avec une servlet classique, le war se déploie sans erreurs avec une écriture en base correct.

  18. #18
    Candidat au Club
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 2
    Points : 2
    Points
    2
    Par défaut [Spring MVC] Injection EJB3 dans le controleur
    Bon finalement j'ai trouvé

    Il faut renseigner le champ mappedName de l'annotation EJB de la manière suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    @EJB(mappedName="java:app/monsite/UserDAO")
    private IUserDAO userDAO;
    monsite est le nom de l'application et UserDAO le nom de la classe qui implémente l'interface IUserDAO.

    En espérant que ça puisse servir à une personne qui passe par là.

Discussions similaires

  1. Injection EJB3 dans la servlet GWT
    Par maccoy54 dans le forum GWT et Vaadin
    Réponses: 1
    Dernier message: 29/01/2011, 19h38
  2. Réponses: 4
    Dernier message: 23/10/2007, 09h14
  3. [SPRING MVC]Erreur sur un Integer dans un Validator
    Par manuzinho dans le forum Spring Web
    Réponses: 2
    Dernier message: 31/08/2007, 15h58
  4. [Spring MVC] Liste déroulante dans un formulaire.
    Par jc63 dans le forum Spring Web
    Réponses: 3
    Dernier message: 26/07/2007, 09h24
  5. [Spring MVC] recuperer le ServletContext dans un Validator
    Par manuzinho dans le forum Spring Web
    Réponses: 1
    Dernier message: 07/08/2006, 14h09

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