Salut ,

Je suis un bleu en JSF 2.0 et j'aimerais accéder à un ejb que j'ai deployé sous glassfish V3, la base de donnée que j'utilise est sur Oracle.
J'ai créé de coté un client javaapplication pour y accéder voici le code :
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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package clientejb3;
import buss.SnBeanRemote;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import mapped.Customer;
import mapped.Dept;
 
import mapped.Product;
 
 
 
 
 
/**
 *
 * @author liquideshark
 */
public class Scott {
 
     /**
     * @param args the command line arguments
     */
 
   public static List getCustom(){
      Properties props = new Properties();
      props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
      props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
      SnBeanRemote rcom =null;
        try {
            InitialContext ic = new InitialContext(props);
             rcom = (SnBeanRemote) ic.lookup("buss.SnBeanRemote");
 
     //List allCust = rcom.getCustomers();
 
 
        } catch (NamingException ex) {
            Logger.getLogger(Exemple2.class.getName()).log(Level.SEVERE, null, ex);
        }
 
      return rcom.getCustomers();
 
  }
 
 
 
 
    public static void main(String[] args) {
        // TODO code application logic here
 
  Properties props = new Properties();
 // props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
 // props.setProperty("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
//  props.setProperty("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
 
 
  // optional.  Defaults to localhost.  Only needed if web server is running
  // on a different host than the appserver
  props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
 
  // optional.  Defaults to 3700.  Only needed if target orb port is not 3700.
  props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
 
        try {
            InitialContext ic = new InitialContext(props);
            SnBeanRemote rcom = (SnBeanRemote) ic.lookup("buss.SnBeanRemote");
 
 
 
 
 
     List allCust = rcom.getCustomers();
     List allDept = rcom.getDepartement();
      List allProduct = rcom.getProduit();
 
 System.out.println("***********  Customer  **************\n\n");
            for (Iterator iter = allCust.iterator(); iter.hasNext();) {
                Customer cust = (Customer) iter.next();
                System.out.println(":Addre:"+cust.getAddress()+":City:"+cust.getCity()+":Name:"+cust.getName()+":Phone:"+cust.getPhone());
            }
  System.out.println("***********  Departement  **************\n\n");
  for (Iterator iter = allDept.iterator(); iter.hasNext();) {
                Dept dep = (Dept) iter.next();
                System.out.println(":Name :"+dep.getDname()+":Localisation: "+dep.getLoc()+":Depnumer: "+dep.getDeptno());
            }
  System.out.println("***********  Produits  ************** \n\n");
  for (Iterator iter = allProduct.iterator(); iter.hasNext();) {
                Product prod = (Product) iter.next();
                System.out.println("Description "+prod.getDescrip()+"ID produit: "+prod.getProdid());
            }
 
 
        } catch (NamingException ex) {
            Logger.getLogger(Exemple2.class.getName()).log(Level.SEVERE, null, ex);
        }
 
 
 List lilo = getCustom();
 
 System.out.println("***********  %%%%%%%%%Customer LILO%%%%%%%  **************\n\n");
            for (Iterator iter = lilo.iterator(); iter.hasNext();) {
                Customer cust = (Customer) iter.next();
                System.out.println(":Addre:"+cust.getAddress()+":City:"+cust.getCity()+":Name:"+cust.getName()+":Phone:"+cust.getPhone());
            }
 
 
 
 
    }
 
}

et voici le résultat :

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
1 avr. 2010 10:31:04 com.sun.enterprise.transaction.JavaEETransactionManagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
***********  Customer  **************
 
 
:Addre:345 VIEWRIDGE:City:BELMONT:Name:JOCKSPORTS:Phone:598-6609
:Addre:490 BOLI RD.:City:REDWOOD CITY:Name:TKB SPORT SHOP:Phone:368-1223
:Addre:9722 HAMILTON:City:BURLINGAME:Name:VOLLYRITE:Phone:644-3341
:Addre:HILLVIEW MALL:City:BURLINGAME:Name:JUST TENNIS:Phone:677-9312
:Addre:574 SURRY RD.:City:CUPERTINO:Name:EVERY MOUNTAIN:Phone:996-2323
:Addre:3476 EL PASEO:City:SANTA CLARA:Name:K + T SPORTS:Phone:376-9966
:Addre:908 SEQUOIA:City:PALO ALTO:Name:SHAPE UP:Phone:364-9777
:Addre:VALCO VILLAGE:City:SUNNYVALE:Name:WOMENS SPORTS:Phone:967-4398
:Addre:98 LONE PINE WAY:City:HIBBING:Name:NORTH WOODS HEALTH AND FITNESS SUPPLY CENTER:Phone:566-9123
***********  Departement  **************
 
 
:Name :ACCOUNTING:Localisation: NEW YORK:Depnumer: 10
:Name :RESEARCH:Localisation: DALLAS:Depnumer: 20
:Name :SALES:Localisation: CHICAGO:Depnumer: 30
:Name :OPERATIONS:Localisation: BOSTON:Depnumer: 40
***********  Produits  ************** 
 
 
Description ACE TENNIS RACKET IID produit: 100860
Description ACE TENNIS RACKET IIID produit: 100861
Description ACE TENNIS BALLS-3 PACKID produit: 100870
Description ACE TENNIS BALLS-6 PACKID produit: 100871
Description ACE TENNIS NETID produit: 100890
Description SP TENNIS RACKETID produit: 101860
Description SP JUNIOR RACKETID produit: 101863
Description RH: "GUIDE TO TENNIS"ID produit: 102130
Description SB ENERGY BAR-6 PACKID produit: 200376
Description SB VITA SNACK-6 PACKID produit: 200380
***********  %%%%%%%%%Customer LILO%%%%%%%  **************
 
 
:Addre:345 VIEWRIDGE:City:BELMONT:Name:JOCKSPORTS:Phone:598-6609
:Addre:490 BOLI RD.:City:REDWOOD CITY:Name:TKB SPORT SHOP:Phone:368-1223
:Addre:9722 HAMILTON:City:BURLINGAME:Name:VOLLYRITE:Phone:644-3341
:Addre:HILLVIEW MALL:City:BURLINGAME:Name:JUST TENNIS:Phone:677-9312
:Addre:574 SURRY RD.:City:CUPERTINO:Name:EVERY MOUNTAIN:Phone:996-2323
:Addre:3476 EL PASEO:City:SANTA CLARA:Name:K + T SPORTS:Phone:376-9966
:Addre:908 SEQUOIA:City:PALO ALTO:Name:SHAPE UP:Phone:364-9777
:Addre:VALCO VILLAGE:City:SUNNYVALE:Name:WOMENS SPORTS:Phone:967-4398
:Addre:98 LONE PINE WAY:City:HIBBING:Name:NORTH WOODS HEALTH AND FITNESS SUPPLY CENTER:Phone:566-9123
BUILD SUCCESSFUL (total time: 3 seconds)
Enfin tous ce passe bien.

Comment ? pourrai-je implémente cela sous un projet JSF2.0 merci.