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

JPA Java Discussion :

[EJB JPA] Impossible d'utiliser la persistence


Sujet :

JPA Java

  1. #1
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Mars 2008
    Messages
    70
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Mars 2008
    Messages : 70
    Par défaut [EJB JPA] Impossible d'utiliser la persistence
    Bonjour,

    J'ai développé des EJB que je deploie sur Glassfish , je souhaite les tester à l'aide d'un client lourd.

    J'arrive a récuperer mon EJB Remote depuis le client lourd , cepedante lorsque j'execute une méthode metier de cet EJB , l'appel à la methode entityFacade.findAll echoue lamentablement.

    JE m'explique sur la manière que j'ai employé pour développer le projet :
    J'ai définit une bdd , puis depuis netbeans j'ai generé les entity beans depuis une nouvelle persistence unit , puis a partir de ces entity j'ai généré les session beans ( facade ) , puis j'ai developper un ejb remote qui encapsule les méthodes métier.

    Voici le code d'un entity :

    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
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package ecom.entity;
     
    import java.io.Serializable;
    import java.util.Collection;
    import javax.persistence.*;
    import javax.validation.constraints.NotNull;
    import javax.validation.constraints.Size;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlTransient;
     
    /**
     *
     * @author Rami
     */
    @Entity
    @Table(name = "customers", catalog = "baptiste", schema = "")
    @XmlRootElement
    @NamedQueries({
        @NamedQuery(name = "Customers.findAll", query = "SELECT c FROM Customers c"),
        @NamedQuery(name = "Customers.findByIdCustomer", query = "SELECT c FROM Customers c WHERE c.idCustomer = :idCustomer"),
        @NamedQuery(name = "Customers.findByLastName", query = "SELECT c FROM Customers c WHERE c.lastName = :lastName"),
        @NamedQuery(name = "Customers.findByFirstName", query = "SELECT c FROM Customers c WHERE c.firstName = :firstName"),
        @NamedQuery(name = "Customers.findByEmail", query = "SELECT c FROM Customers c WHERE c.email = :email"),
        @NamedQuery(name = "Customers.findByPassword", query = "SELECT c FROM Customers c WHERE c.password = :password")})
    public class Customers implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @Basic(optional = false)
        @NotNull
        @Column(name = "idCustomer")
        private Integer idCustomer;
        @Size(max = 45)
        @Column(name = "lastName")
        private String lastName;
        @Size(max = 45)
        @Column(name = "firstName")
        private String firstName;
        // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
        @Size(max = 255)
        @Column(name = "email")
        private String email;
        @Size(max = 45)
        @Column(name = "password")
        private String password;
        @JoinTable(name = "customer_has_adress", joinColumns = {
            @JoinColumn(name = "customer_id", referencedColumnName = "idCustomer")}, inverseJoinColumns = {
            @JoinColumn(name = "adress_id", referencedColumnName = "idAdress")})
        @ManyToMany
        private Collection<Adress> adressCollection;
        @JoinColumn(name = "account_id", referencedColumnName = "idAccount")
        @ManyToOne(optional = false)
        private Account accountId;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "customerId")
        private Collection<Orders> ordersCollection;
     
        public Customers() {
        }
     
        public Customers(Integer idCustomer) {
            this.idCustomer = idCustomer;
        }
     
        public Integer getIdCustomer() {
            return idCustomer;
        }
     
        public void setIdCustomer(Integer idCustomer) {
            this.idCustomer = idCustomer;
        }
     
        public String getLastName() {
            return lastName;
        }
     
        public void setLastName(String lastName) {
            this.lastName = lastName;
        }
     
        public String getFirstName() {
            return firstName;
        }
     
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }
     
        public String getEmail() {
            return email;
        }
     
        public void setEmail(String email) {
            this.email = email;
        }
     
        public String getPassword() {
            return password;
        }
     
        public void setPassword(String password) {
            this.password = password;
        }
     
        @XmlTransient
        public Collection<Adress> getAdressCollection() {
            return adressCollection;
        }
     
        public void setAdressCollection(Collection<Adress> adressCollection) {
            this.adressCollection = adressCollection;
        }
     
        public Account getAccountId() {
            return accountId;
        }
     
        public void setAccountId(Account accountId) {
            this.accountId = accountId;
        }
     
        @XmlTransient
        public Collection<Orders> getOrdersCollection() {
            return ordersCollection;
        }
     
        public void setOrdersCollection(Collection<Orders> ordersCollection) {
            this.ordersCollection = ordersCollection;
        }
     
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (idCustomer != null ? idCustomer.hashCode() : 0);
            return hash;
        }
     
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof Customers)) {
                return false;
            }
            Customers other = (Customers) object;
            if ((this.idCustomer == null && other.idCustomer != null) || (this.idCustomer != null && !this.idCustomer.equals(other.idCustomer))) {
                return false;
            }
            return true;
        }
     
        @Override
        public String toString() {
            return "ecom.entity.Customers[ idCustomer=" + idCustomer + " ]";
        }
     
    }
    Voici le code d'un sesionbean :
    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
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package ecom.entityFacade;
     
    import ecom.entity.Customers;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
     
    /**
     *
     * @author Rami
     */
    @Stateless
    public class CustomersFacade extends AbstractFacade<Customers> implements CustomersFacadeLocal {
        @PersistenceContext(unitName = "EnterpriseApplication2-ejbPU")
        private EntityManager em;
     
        @Override
        protected EntityManager getEntityManager() {
            return em;
        }
     
        public CustomersFacade() {
            super(Customers.class);
        }
     
        public Customers findByEmail(String email) {
          Query q = em.createNamedQuery("Customers.findByEmail").setParameter("email", email);
          return (Customers) q.getSingleResult();
        }
     
         public Customers findByName(String name) {
             Query q = em.createNamedQuery("Customers.findByLastName").setParameter("lastName", name);
           return (Customers) q.getSingleResult();
        }
          public List<Customers> findAll2() {
             Query q = em.createNamedQuery("Customers.findAll");
           return (List<Customers>)  q.getResultList();
        }
     
    }
    Voici le code de mon remote :
    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
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
     
    package ecom.session;
     
    import ecom.exception.EcomException;
     
    import ecom.entity.Account;
    import ecom.entity.Adress;
    import ecom.entity.Categories;
    import ecom.entity.Country;
    import ecom.entity.Customers;
    import ecom.entity.Products;
    import ecom.entity.ProductStore;
    import ecom.entity.Stores;
    import ecom.entityFacade.*;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Remote;
    import javax.ejb.Stateful;
     
    @Stateful
    //@Remote(EcomAdminRemote.class)
    public class EcomAdminBean extends EcomGenericBean implements EcomAdminRemote {
     
     
        /********** METHODE POUR LES ACCOUNT
         * createAccount
         * listAccount
         * modifyAccount
         * deleteAccount
         */
        /**
         *
         * @param iban : iban du compte
         * @param accountOwner : correspond au nom  dans le cas d'un client, ou du nom du magazin dans le cas d'un store
         * @param balance : balance du compte
         */
     
        @Override
       public void createAccount(String iban, String accountOwner, double balance) throws EcomException {
            //Creation de l'Account
            Account account = new Account();
            account.setIban(iban);
            account.setBalance(Double.valueOf(balance));
     
            // Creation du DAO pour creer le compte
            AccountFacade accountDao = new AccountFacade();
            accountDao.create(account);
     
     
            // mise a jour de l'utilisateur qui possede le nouveau compte
            CustomersFacade customerDao = new CustomersFacade();
            Customers c = customerDao.findByName(accountOwner);
     
            if (null == c) {
                // il s'agit d'un store
                throw new EcomException("On ne peut pas encore ajouter de compte pour un store");
            } else {
                // il s'agit d'un customer
                c.setAccountId(account);
                customerDao.edit(c);
            }
     
        }
     
        @Override
        public void createCategory(String label, String description) throws EcomException {
            //Creation de l'Account
            Categories category = new Categories();
            category.setLabel(label);
            category.setDescription(description);
     
     
     
            // Creation du DAO pour creer le compte
            CategoriesFacade categoryDao = new CategoriesFacade();
            categoryDao.create(category);
     
     
        }
     
        @Override
        public void deleteCategory(int id) {
            Categories c = null;
            CategoriesFacade categoryDao = new CategoriesFacade();
     
            c = categoryDao.find(id);
            categoryDao.remove(c);
     
        }
     
        @Override
        /**
         * List
         */
        public List<Account> listAccount() {
            AccountFacade accountDao = new AccountFacade();
            List<Account> accountList = accountDao.findAll();
            return accountList;
        }
     
        @Override
        /**
         * List
         */
        public Account getAccountByIban(String iban) {
            AccountFacade accountDao = new AccountFacade();
            Account account = accountDao.findByIban(iban);
     
            return account;
        }
     
        @Override
        /**
         * List
         */
        public Account getAccountById(int id) {
            AccountFacade accountDao = new AccountFacade();
            Account account = accountDao.find(id);
            return account;
        }
     
        @Override
        /**
         * Permet de modifier la balance d'un compte a partir de son iban
         */
        public void modifyAccount(int id, String iban, double balance) {
            AccountFacade accountDao = new AccountFacade();
            Account account = accountDao.find(id);
            account.setIban(iban);
            account.setBalance(balance);
            accountDao.edit(account);
        }
     
        @Override
        public void deleteAccount(int id) {
            Account a = null;
            AccountFacade accountDao = new AccountFacade();
     
            a = accountDao.find(id);
            accountDao.remove(a);
     
        }
     
        /********** METHODE POUR LES STORES
         * createStore
         * listStore
         * modifyStore
         * deleteStore
         */
        /**
         *  Créer un magasin à partir de son nom
         * @param name 
         */
        public void createStore(String name) {
            //Creation de l'Account
            Account account = new Account();
            Integer idAccount =0;
            account.setIdAccount(idAccount);
     
     
            //Création du store
            Stores store = new Stores();
            store.setName(name);
            store.setAccountId(account);
     
     
     
            // Creation du DAO pour creer le compte
            StoresFacade storeDAO = new StoresFacade();
            storeDAO.create(store);
     
     
        }
     
        @Override
        public void modifyStore(Integer storeId, String newNameStore) {
            //Recherche du store correspondant à l'id
            Stores store = new Stores();
     
            //Création des dao
            StoresFacade storeDAO = new StoresFacade();
            store = storeDAO.find(storeId);
     
            //changement
            store.setName(newNameStore);
     
            //transaction
            storeDAO.edit(store);
        }
     
        @Override
        public void associateProductToStore(int productId, int storeId, int stock, Double price) throws EcomException {
           Stores store = new Stores();
           Products product = new Products();
           StoresFacade storeDAO = new StoresFacade();
           ProductsFacade productDAO = new ProductsFacade();
     
     
           store = storeDAO.find(storeId);
           product = productDAO.find(productId);
     
           if(null == store) {
               throw new EcomException("le Store avec l'id "+storeId+" n'existe pas");
           } else if(null == product) {
               throw new EcomException("le Product avec l'id "+productId+" n'existe pas");
           } else {
               ProductStore productStore = new ProductStore(storeId, productId);
               ProductStoreFacade productStoreDAO = new ProductStoreFacade();
               productStore.setPrice(price);
               productStore.setStock(stock);
               productStoreDAO.create(productStore);
           } 
     
     
        }
     
        @Override
        public void associateAccountToStore(Integer storeId, Integer accountID) {
            //Recherche du store correspondant à l'id
            Stores store = new Stores();
            StoresFacade storeDAO = new StoresFacade();
            store = storeDAO.find(storeId);
     
            //recherche du compte
            Account account =  new Account();
            AccountFacade accountDAO = new AccountFacade();
            account = accountDAO.find(accountID);
     
            //association du compte au store
            store.setAccountId(account) ;
     
            //transaction
            storeDAO.edit(store);
     
     
        }
     
        /**
         * Supprime un magasin a partir de son ID
         * @param storeId 
         */
        @Override
        public void deleteStore(Integer storeId) {
     
            //Recherche du store correspondant à l'id
            Stores store = new Stores();
     
            //Création des dao
            StoresFacade storeDAO = new StoresFacade();
            store = storeDAO.find(storeId);
     
            //suprresion du store
            storeDAO.remove(store);
        }
     
        public void createProduct(String productName, String description, int categoryId) throws EcomException {
            Products product = new Products();
            ProductsFacade productDAO = new ProductsFacade();
            CategoriesFacade categoryDAO = new CategoriesFacade();
            product.setName(productName);
            product.setDescription(description);
     
            Categories category = categoryDAO.find(categoryId);
     
            if (null == category) {
                throw new EcomException("La categorie n'existe pas");
            } else {
                // il s'agit d'un customer
                product.setCategoryId(category);
                productDAO.create(product);
            }
     
        }
     
        /********** METHODE POUR LES CUSTOMERS
         * createCustomer
         * listCustomer
         * modifyCustomer
         * deleteCustomer
         */
        @Override
        public List<Customers> listCustomer() {
            List<Customers> customerList  ;
            CustomersFacade customerDao = new CustomersFacade();
            customerList = customerDao.findAll2();
     
            return customerList;
        }
     
        /**
         * Permet de creer un customer a partir d'un compte existant
         * @param lastName
         * @param firstName
         * @param email
         * @param password
         * @param street
         * @param zipCode
         * @param city
         * @param countryId
         * @param idAccount
         * @throws EcomException 
         */
        @Override
        public void createCustomer(String lastName, String firstName, String email, String password, String street, String zipCode, String city, int countryId, int idAccount) throws EcomException {
            // Declarations des DAOs
            CustomersFacade customerDAO = new CustomersFacade();
            AdressFacade adressDAO = new AdressFacade();
            AccountFacade accountDAO = new AccountFacade();
     
            // Creation des references de l'objet customer
            Customers customer = new Customers();
            Adress adress = new Adress();
            List<Adress> adressList = new ArrayList();
     
            adress.setCity(city);
            adress.setStreet(street);
            adress.setZipcode(zipCode);
            adress.setCountryId(new Country(countryId));
     
            adressList.add(adress);
     
            customer.setFirstName(firstName);
            customer.setLastName(lastName);
            customer.setEmail(email);
            customer.setPassword(password);
            customer.setAdressCollection(adressList);
     
            Account a= accountDAO.find(idAccount);
     
            if (null == a) {
                throw new EcomException("L'account n'existe pas");
            } else {
                // Debut des transactions
                customer.setAccountId(a);
                adressDAO.create(adress);
                customerDAO.create(customer);
            }
            // fermeture des session
        }
     
        /**
         * Permet de creer un customer y compris le compte
         * @param lastName
         * @param firstName
         * @param email
         * @param password
         * @param street
         * @param zipCode
         * @param city
         * @param countryId
         * @param iban
         * @param balance
         * @throws EcomException 
         */
        public void createCustomer(String lastName, String firstName, String email, String password, String street, String zipCode, String city, int countryId, String iban, double balance) {
            // Declarations des DAOs
            CustomersFacade customerDAO = new CustomersFacade();
            AdressFacade adressDAO = new AdressFacade();
            AccountFacade accountDAO = new AccountFacade();
     
            // Creation des references de l'objet customer
            Customers customer = new Customers();
            Adress adress = new Adress();
            List<Adress> adressList = new ArrayList();
            Account account = new Account();
     
            adress.setCity(city);
            adress.setStreet(street);
            adress.setZipcode(zipCode);
            adress.setCountryId(new Country(countryId));
     
            adressList.add(adress);
     
            account.setIban(iban);
            account.setBalance(balance);
     
            customer.setFirstName(firstName);
            customer.setLastName(lastName);
            customer.setEmail(email);
            customer.setPassword(password);
            customer.setAdressCollection(adressList);
            customer.setAccountId(account);
     
            // Debut des transactions
            accountDAO.create(account);
            adressDAO.create(adress);
            customerDAO.create(customer);
     
        }
     
        @Override
        public void modifyCustomer(String lastName, String firtName, String email) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
     
        @Override
        public void deleteCustomer(int id) {
            Customers c = null;
            CustomersFacade customerDao = new CustomersFacade();
     
            c = customerDao.find(id);
            customerDao.remove(c);
        }
     
        @Override
        public void addAdressToCustomer(Customers c) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
     
        @Override
        /**
         * Permet de lister les country afin de saisir la totalite de l'adresse pour la creation d'un customer
          */
        public List<Country> listCountry() {
            List<Country> countryList = null;
            CountryFacade dao = new CountryFacade();
            countryList = dao.findAll();
            return countryList;
        }
     
        @Override
        public List<Products> listProducts() {
            List<Products> productList = null;
            ProductsFacade productDAO = new ProductsFacade();
            productList = productDAO.findAll();
            return productList;
        }
     
     
        /**
         * liste les produits d'un store
         * @param idStore
         * @return la liste des produits d'un store
         */
     
        @Override
        public List<ProductStore> listProductsStore(int idStore) {
            List<ProductStore> productStoreList = null;
            ProductStoreFacade productStoreDAO = new ProductStoreFacade();
            productStoreList = productStoreDAO.findByStoreId(idStore);
            return productStoreList;
        }
     
     
        /**
         * Liste les produits d'un catégorie
         * @param idCategory
         * @return une liste de produit
         */
    /*    
        @Override
        public List<Product> listProductsByCategory(int idCategory) {
            List<Product> productList = null;
            ProductDAO productDAO = new ProductDAO();
            productList = productDAO.findAllByCategory(idCategory);
            productDAO.closeSession();
            return productList;
        }
    */
     
        /**
         * Liste toutes les catégories
         */
        public List<Categories> listCategory() {
            CategoriesFacade categoryDao = new CategoriesFacade();
            List<Categories> categoryList = categoryDao.findAll();
     
            return categoryList;
        }
     
        @Override
        /**
         * Retourne la catégorie en fonction de l'id
         */
        public Categories findCategory(int idCategory) {
            CategoriesFacade categoryDao = new CategoriesFacade();
            Categories category = categoryDao.find(idCategory);
     
            return category;
        }
     
        @Override
        public List<Products> findProductsByInName(String inName) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }
    Voici la trace lors d'un appel de la methodes customersFacade.findAll :
    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
     
    ATTENTION: EJB5184:A system exception occurred during an invocation on EJB EcomAdminBean, method: public java.util.List ecom.session.EcomAdminBean.listCustomer()
    ATTENTION: javax.ejb.EJBException
    	at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5215)
    	at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5113)
    	at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4901)
    	at com.sun.ejb.containers.StatefulSessionContainer.postInvokeTx(StatefulSessionContainer.java:1651)
    	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045)
    	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
    	at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:213)
    	at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
    	at $Proxy256.listCustomer(Unknown Source)
    	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:597)
    	at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:144)
    	at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:174)
    	at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:528)
    	at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:199)
    	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1624)
    	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1486)
    	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:990)
    	at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:214)
    	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:742)
    	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:539)
    	at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2324)
    	at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
    	at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
    Caused by: java.lang.NullPointerException
    	at ecom.entityFacade.CustomersFacade.findAll2(CustomersFacade.java:42)
    	at ecom.session.EcomAdminBean.listCustomer(EcomAdminBean.java:290)
    	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:597)
    	at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
    	at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
    	at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:4180)
    	at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5368)
    	at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
    	at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:206)
    	... 19 more

    Si quelqu'un à une idée ou si y a besoin de plus d'informations n'hesitez pas à vous manifester.

    Merci par avance

    Cordialement

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    52
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 52
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    // Creation du DAO pour creer le compte
            AccountFacade accountDao = new AccountFacade();
    Les EJB ne s'initialisent pas avec des new mais avec des @EJB déclarés en attributs de la classe.

Discussions similaires

  1. Problème EJB JPA persistance méthode persist
    Par murder dans le forum JPA
    Réponses: 15
    Dernier message: 05/12/2011, 15h12
  2. Réponses: 4
    Dernier message: 02/08/2008, 19h56
  3. Impossible d'utiliser DISTINCT avec des types image et ntext
    Par azlinch dans le forum MS SQL Server
    Réponses: 4
    Dernier message: 17/08/2005, 18h43
  4. impossible d'utiliser un HWND parent dans un thread
    Par sylvain114d dans le forum Windows
    Réponses: 12
    Dernier message: 23/09/2004, 13h21
  5. impossible d'utiliser ma fonction dans un insert
    Par caramel dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 10/04/2003, 16h04

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