Bonjour à vous!J'ai deux modules maven l'un est un module EJB et l'autre un module web.
voici le managed bean dans le module web
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
 
package com.better;
 
import java.util.Collection;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import modele.Pays;
import parametrage.IConfigInitial;
 
/**
 *
 * @author fabrice
 */
@ManagedBean(name="payscontroller")
@RequestScoped
public class PaysController {
 
    /**
     * Creates a new instance of PaysController
     */
    @EJB
   private IConfigInitial ConfigInitial;
 
    private Pays pays;
    public PaysController() {
    }
 
    public Collection<Pays> getPays() {
        return ConfigInitial.getAllPays();
    }
 
}
Puis dans le module EJB j'ai 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
 
package parametrage;
 
import java.util.Collection;
import java.util.Map;
import javax.ejb.Local;
import javax.ejb.Remote;
import modele.*;
 
/**
 *
 * @author fabrice
 */
@Local
public interface IConfigInitial {
    //Lister les pays
    public Collection<Pays> getAllPays();
 
}
et
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
 
package parametrage;
 
import dao.PaysDao;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import modele.*;
 
/**
 *
 * @author fabrice
 */
@Stateless
public class ConfigInitialBean implements IConfigInitial{
 
    @EJB
    private PaysDao paysbean;
 
    private Collection<Pays> listpays=new ArrayList<Pays>();
    private Collection<Periode> listperiode=new ArrayList<Periode>();
    Pays p=new Pays();
    Periode period=new Periode();
    @Override
    public Collection<Pays> getAllPays() {
        String Continent="Afrique";
        // on teste s'il n'y a pas encore de pays
       listpays= paysbean.findAll();
            if(listpays.isEmpty()|| listpays==null){
 
              listpays.add(new Pays("CM","CAMEROUN", "CAMEROON", Continent)); 
              listpays.add(new Pays("GA","GABON", "GABON", Continent));
               listpays.add(new Pays("ZA","AFRIQUE DU SUD", "SOUTH AFRICA", Continent));
               listpays.add(new Pays("AO","ANGOLA", "ANGOLA", Continent));
               listpays.add(new Pays("BJ","BENIN", "BENIN", Continent));
               listpays.add(new Pays("BW","BOTSWANA", "BOTSWANA", Continent));
               listpays.add(new Pays("BF","BURKINA FASO", "BURKINA FASO", Continent));
               listpays.add(new Pays("CV","CAP-VERT", "CAPE VERDE", Continent));
               listpays.add(new Pays("CF","CENTRAFRIQUE", "CENTRAFRICA", Continent));
               listpays.add(new Pays("CG","CONGO", "CONGO", Continent));
               listpays.add(new Pays("CD","CONGO RD", "CONGO RD", Continent));
               listpays.add(new Pays("CI","COTE D'IVOIRE", "COTE D'IVOIRE", Continent));
               listpays.add(new Pays("EG","EGYPTE", "EGYPT", Continent));
               listpays.add(new Pays("ET","ETHIOPIE", "ETHIOPIA", Continent));
               listpays.add(new Pays("GM","GAMBIE", "GAMBIA", Continent));
               listpays.add(new Pays("GH","GHANA", "GHANA", Continent));
               listpays.add(new Pays("GN","GUINEE", "GUINEA", Continent));
               listpays.add(new Pays("GW","GUINEE-BISSAU", "GUINEA-BISSAU", Continent));
               listpays.add(new Pays("GQ","GUINEE EQUATORIALE", "EQUATORIAL GUINEA", Continent));
               listpays.add(new Pays("KE","KENYA", "KENYA", Continent));
               listpays.add(new Pays("LR","LIBERIA", "LIBERIA", Continent));
               listpays.add(new Pays("MG","MADAGASCAR", "MADAGASCAR", Continent));
               listpays.add(new Pays("ML","MALI", "MALI", Continent));
               listpays.add(new Pays("NA","NAMIBIE", "NAMIBIA", Continent));
               listpays.add(new Pays("NG","NIGERIA", "NIGERIA", Continent));
               listpays.add(new Pays("NE","NIGER", "NIGER", Continent));
               listpays.add(new Pays("SN","SENEGAL", "SENEGAL", Continent));
               listpays.add(new Pays("TD","TCHAD", "CHAD", Continent));
               listpays.add(new Pays("TG","TOGO", "Gabon", Continent));
               listpays.add(new Pays("TN","TUNISIE", "TUNISIA", Continent));
               listpays.add(new Pays("ZM","ZAMBIE", "ZAMBIA", Continent));
               listpays.add(new Pays("ZW","ZIMBABWE", "ZIMBABWE", Continent));
            paysbean.createAll(listpays);
            }
            return listpays;
    }
 
 
 
 
}
Le module EJB est une dépendance du module web.Lors de l'execution voici l'erreur
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
com.sun.faces.mgbean.ManagedBeanCreationException: Erreur lors de l?injection de ressources dans le bean géré «payscontroller»
	at com.sun.faces.mgbean.BeanBuilder.injectResources(BeanBuilder.java:211)
	at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103)
	at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
	at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
	at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
	at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
	at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
	at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
	at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:99)
	at com.sun.el.parser.AstValue.getValue(AstValue.java:158)
	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
	at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
	at javax.faces.component.UIData.getValue(UIData.java:731)
	at javax.faces.component.UIData.getDataModel(UIData.java:1798)
	at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484)
	at javax.faces.component.UIData.setRowIndex(UIData.java:473)
	at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:81)
	at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
	at javax.faces.component.UIData.encodeBegin(UIData.java:1118)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1754)
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
	at java.lang.Thread.run(Thread.java:722)
Caused by: com.sun.faces.spi.InjectionProviderException: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=com.better.PaysController/ConfigInitial,Remote 3.x interface =parametrage.IConfigInitial,ejb-link=null,lookup=,mappedName=,jndi-name=parametrage.IConfigInitial,refType=Session into class com.better.PaysController: Lookup failed for 'java:comp/env/com.better.PaysController/ConfigInitial' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
	at org.glassfish.faces.integration.GlassFishInjectionProvider.inject(GlassFishInjectionProvider.java:194)
	at com.sun.faces.mgbean.BeanBuilder.injectResources(BeanBuilder.java:205)
	... 57 more
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=com.better.PaysController/ConfigInitial,Remote 3.x interface =parametrage.IConfigInitial,ejb-link=null,lookup=,mappedName=,jndi-name=parametrage.IConfigInitial,refType=Session into class com.better.PaysController: Lookup failed for 'java:comp/env/com.better.PaysController/ConfigInitial' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
	at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:703)
	at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:470)
	at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:171)
	at org.glassfish.faces.integration.GlassFishInjectionProvider.inject(GlassFishInjectionProvider.java:184)
	... 58 more
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/com.better.PaysController/ConfigInitial' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=com.better.PaysController/ConfigInitial,Remote 3.x interface =parametrage.IConfigInitial,ejb-link=null,lookup=,mappedName=,jndi-name=parametrage.IConfigInitial,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'parametrage.IConfigInitial#parametrage.IConfigInitial' [Root exception is javax.naming.NamingException: Lookup failed for 'parametrage.IConfigInitial#parametrage.IConfigInitial' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: parametrage.IConfigInitial#parametrage.IConfigInitial not found]]]
	at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
	at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
	at javax.naming.InitialContext.lookup(InitialContext.java:411)
	at javax.naming.InitialContext.lookup(InitialContext.java:411)
	at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:599)
	... 61 more
Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=com.better.PaysController/ConfigInitial,Remote 3.x interface =parametrage.IConfigInitial,ejb-link=null,lookup=,mappedName=,jndi-name=parametrage.IConfigInitial,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'parametrage.IConfigInitial#parametrage.IConfigInitial' [Root exception is javax.naming.NamingException: Lookup failed for 'parametrage.IConfigInitial#parametrage.IConfigInitial' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: parametrage.IConfigInitial#parametrage.IConfigInitial not found]]
	at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:178)
	at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1106)
	at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776)
	at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744)
	at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:172)
	at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498)
	... 65 more
Caused by: javax.naming.NamingException: Lookup failed for 'parametrage.IConfigInitial#parametrage.IConfigInitial' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: parametrage.IConfigInitial#parametrage.IConfigInitial not found]
	at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
	at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
	at javax.naming.InitialContext.lookup(InitialContext.java:411)
	at javax.naming.InitialContext.lookup(InitialContext.java:411)
	at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:173)
	... 70 more
Caused by: javax.naming.NameNotFoundException: parametrage.IConfigInitial#parametrage.IConfigInitial not found
	at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
	at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
	at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
	at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
	at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)
Cordialement.