Bonsoir tout le monde.
Voilà, dans le cadre de mes cours, je suis amené à programmer
des applications EJB avec Jonas.
Au début tout fonctionnait parfaitement et la aujourd'hui plus rien de marche.
J'ai plusieurs projet et tous me donnent la même erreur.
Je vous joins le code d'un projet bateau qui s'appel HelloEJB.
Alors voici l'erreur :
javax.naming.NamingException: javax.naming.NameNotFoundException: helloHome
Caused by: javax.naming.NameNotFoundException: helloHome
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:99)
at javax.naming.InitialContext.lookup(InitialContext.java:396)
at org.objectweb.carol.jndi.spi.JRMPContext.lookup(JRMPContext.java:161)
at org.objectweb.carol.jndi.spi.JRMPContext.lookup(JRMPContext.java:165)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.objectweb.carol.jndi.spi.ContextWrapper.lookup(ContextWrapper.java:112)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at hw.helloClient.main(helloClient.java:33)
<End of Cause>
at org.objectweb.carol.jndi.spi.ContextWrapper.lookup(ContextWrapper.java:122)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at hw.helloClient.main(helloClient.java:33)
Et voici le code de mes fichiers :
hello.java :
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 // hello.java package hw; import java.rmi.RemoteException; import javax.ejb.EJBObject; /** * hello remote interface */ public interface hello extends EJBObject { // public void method1() throws RemoteException; // public void method2(java.lang.String s) throws RemoteException; public String sayHello() throws RemoteException; }
helloClient.java :
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 // helloClient.java // mini Client for accessing bean hello package hw; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; /** * */ public class helloClient { static Context ctx = null; static helloHome home = null; public static void main(String[] arg) { // Get InitialContext try { ctx = getInitialContext(); } catch (NamingException e) { e.printStackTrace(); System.exit(2); } // Lookup bean home String bName = "helloHome"; try { home = (helloHome) PortableRemoteObject.narrow(ctx.lookup(bName), helloHome.class); hello bean = home.create(); System.out.println(bean.sayHello()); } catch(Exception e) { e.printStackTrace(); System.exit(2); } // ... } /** * Using a Properties object will work on JDK 1.1.x and Java2 * clients */ static private Context getInitialContext() throws NamingException { String url = "rmi://localhost:1099"; try { // Get an InitialContext Properties h = new Properties(); h.put(Context.INITIAL_CONTEXT_FACTORY, "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory"); h.put(Context.PROVIDER_URL, url); return new InitialContext(h); } catch (NamingException ne) { ne.printStackTrace(); throw ne; } } }
helloEJB.java :
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 // helloEJB.java // Stateless Session bean package hw; import javax.ejb.CreateException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; /** * */ public class helloEJB implements SessionBean { SessionContext ejbContext; // ------------------------------------------------------------------ // SessionBean implementation // ------------------------------------------------------------------ public void setSessionContext(SessionContext ctx) { ejbContext = ctx; } public void ejbRemove() { } public void ejbCreate() throws CreateException { } public void ejbPassivate() { } public void ejbActivate() { } // ------------------------------------------------------------------ // hello implementation // ------------------------------------------------------------------ // /** // * method1 // */ // public void method1() { // } // // /** // * method2 // */ // public void method2(java.lang.String s) { // } // ------------------------------------------------------------------ // hello implementation // ------------------------------------------------------------------- public String sayHello() { return "Envoi de texte depuis l'EJB"; } }
helloHome.java :
Voilà si quelque passe par la et peut partager son savoir je suis preneur.
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 // helloHome.java package hw; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBHome; /** * Home interface for the bean hello */ public interface helloHome extends EJBHome { hello create() throws CreateException, RemoteException; }
Merci d'avance.
Bien amicalement BOOBS60.
Partager