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

NetBeans Java Discussion :

(NB6.7.1,JPA) erreur 401 (accès refusé) au déploiement


Sujet :

NetBeans Java

  1. #1
    Membre actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2006
    Messages
    958
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2006
    Messages : 958
    Points : 213
    Points
    213
    Par défaut (NB6.7.1,JPA) erreur 401 (accès refusé) au déploiement
    bonsoir,

    j'ai une erreur 401 (accès refusé) en tentant de tester un projet JPA (simple)sous netbeans 6.7.
    voila ce que j'ai fait:
    j'ai créé un projet enterprise application qui est le projet principal; il contient la classe Main, le serveur est glassfish v2.1, il contient un projet ejb (un "ejb module") et un projet client.
    dans le projet ejb, je créé un EJB entity nommé "voiture", qui contient tout ce qu'un POJO se doit d'avoir pour les champs: id et nom (string).
    A sa création (de l'entity), j'ai créé une "persistence unit" en précisant l'utilisation de JTA.
    je précise que je ne suis pas très fort là-dessus...
    je continue:
    j'ai créé dans le projet "client" une méthode main dans la classe Main, je vais dedans et j'entre : "System.out.println("hello");".
    voila, c'est fini.
    mon but est de mettre en évidence la création de la table dans mysql mais rien n'est créé et en plus j'ai une erreur:

    Distributing C:\Documents and Settings\lolveley\My Documents\NetBeansProjects\ApplicationClient3\dist\ApplicationClient3.jar to [localhost:4848_server]
    Start registering the project's server resources
    Finished registering server resources
    Deployment of application failed - HTTP connection failed: 401 Unauthorized
    C:\Documents and Settings\lolveley\My Documents\NetBeansProjects\ApplicationClient3\nbproject\build-impl.xml:551: The module has not been deployed.
    BUILD FAILED (total time: 1 minute 1 second)
    une erreur de connexion?...
    j'ai essayé d'activer le moniteur HTTP, sur le port 4848 et j'ai effectivement réussi à m'y connecter, en utilisant le même login +mot de passe que celui que j'ai précisé au lancement du projet EAR.
    dans ce moniteur d'administration, je n'ai pas trouvé mon projet...

    j'ai essayé de désactiver mon firewall (zoneAlarm) et mon antivirus (avast!) mais sans succès...

    pouvez-vous m'aider?
    ou me dire le cas échéant si ce que j'ai fait est correct...

    olivier.

  2. #2
    Expert confirmé
    Avatar de X-plode
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2005
    Messages
    682
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Décembre 2005
    Messages : 682
    Points : 4 883
    Points
    4 883
    Par défaut
    Bonsoir,

    Tu peux faire deux choses.

    La première, regardé les processus qui utilisent les ports 4848.
    La deuxième, tu peux poster ton programme et je pourrais tester sous netbeans si j'ai la même erreur que toi.

  3. #3
    Membre actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2006
    Messages
    958
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2006
    Messages : 958
    Points : 213
    Points
    213
    Par défaut
    bonsoir,

    merci pour ta réponse.
    mais comment puis-je lister les processus qui utilisent le port 4848?
    j'ai regardé le gerstionnaire des tâches mais il ne propose pas une telle option.
    pour le programme, voila:

    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
    package source;
     
    import java.io.Serializable;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
     
    /**
     *
     * @author lolveley
     */
    @Entity
    public class NewEntity implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
     
        public Long getId() {
            return id;
        }
     
        public void setId(Long id) {
            this.id = id;
        }
     
        /**
         * @return the name
         */
        public String getName() {
            return name;
        }
     
        /**
         * @param name the name to set
         */
        public void setName(String name) {
            this.name = name;
        }
     
        private String name;
     
     
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (id != null ? id.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 NewEntity)) {
                return false;
            }
            NewEntity other = (NewEntity) object;
            if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
                return false;
            }
            return true;
        }
     
        @Override
        public String toString() {
            return "source.NewEntity[id=" + id + "]";
        }
     
    }
    main:
    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
    package applicationclient3;
     
    /**
     *
     * @author lolveley
     */
    public class Main {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            System.out.println("hello");
        }
     
    }
    olivier.

  4. #4
    Expert confirmé
    Avatar de X-plode
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2005
    Messages
    682
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Décembre 2005
    Messages : 682
    Points : 4 883
    Points
    4 883
    Par défaut
    Normalement il n'y a aucun soucis dans ton code.

    Je suppose que tu es sous Windows.

    Pour lister tu as ceci.

    Ou sinon, la commande netstat en console.

  5. #5
    Membre actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2006
    Messages
    958
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2006
    Messages : 958
    Points : 213
    Points
    213
    Par défaut
    salut,

    j'ai lancé netstat, et aucun processus n'utilise le port 4848...
    donc rien de ce côté-là.

    comment faire mnt?

  6. #6
    Membre actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2006
    Messages
    958
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2006
    Messages : 958
    Points : 213
    Points
    213
    Par défaut
    j'ai desactivé le firewall et l' antivirus et ça marche mnt.
    mais je n'ai toujours pas de table créée.
    étudions plus en détails ce point: le module ejb contient une entity "newEntity" et un fichier de persistance persistence.xml.
    le projet EAR contient une référence au jar du module ejb.

    voici les fichiers:
    persistence.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" 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">
      <persistence-unit name="test_dev-ejbPU" transaction-type="RESOURCE_LOCAL">
     
        <provider>oracle.toplink.essentials.PersistenceProvider</provider>
        <non-jta-data-source>jdbc/jbossdb</non-jta-data-source>
        <properties>
          <property name="toplink.ddl-generation" value="create-tables"/>
        </properties>
      </persistence-unit>
    </persistence>
    et le main.java dans le projet client:
    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
    package applicationclient3;
     
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
     
    /**
     *
     * @author lolveley
     */
    public class Main {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            System.out.println("hello");
            EntityManagerFactory factory = Persistence.createEntityManagerFactory("test_dev-ejbPU");
            EntityManager em = factory.createEntityManager();
     
            em.getTransaction().begin();
            em.flush();
            em.getTransaction().commit();
     
     
        }
    et l'ensemble des 2 donne cette 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
    hello
    Aug 15, 2009 1:35:59 PM com.sun.enterprise.appclient.MainWithModuleSupport <init>
    WARNING: ACC003: Application threw an exception.
    javax.persistence.PersistenceException: No Persistence provider for EntityManager named test_dev-ejbPU:  No META-INF/persistence.xml was found in classpath.
     
            at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
            at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
            at applicationclient3.Main.main(Main.java:23)
            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.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
            at com.sun.enterprise.appclient.Main.main(Main.java:200)
    Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:461)
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
            at com.sun.enterprise.appclient.Main.main(Main.java:200)
    Caused by: java.lang.reflect.InvocationTargetException
            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.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
            at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
            ... 2 more
    Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named test_dev-ejbPU:  No META-INF/persistence.xml was found in classpath.
     
            at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
            at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
            at applicationclient3.Main.main(Main.java:23)
            ... 8 more
    Java Result: 1
    run-ApplicationClient3:
    run:
    BUILD SUCCESSFUL (total time: 6 seconds)
    il ne semble pas trouver persistence.xml mais ce dernier se trouve bien dans le projet ejb...certes, il n'existe pas dans le projet EAR.
    le persistence.xml est valide?

    olivier.

  7. #7
    Expert confirmé
    Avatar de X-plode
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2005
    Messages
    682
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Décembre 2005
    Messages : 682
    Points : 4 883
    Points
    4 883
    Par défaut
    Salut,

    Il faut que tu fasses ainsi :

    Entities => DAO => Appel

    DAO exemple :

    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
     
    @Stateless
    public class AnimalsFacade implements AnimalsFacadeRemote {
     
        @PersistenceContext
        private EntityManager em;
        private static Map<String, Animals> animalsMap = new LinkedHashMap<String, Animals>();
        private List<Animals> animalsList;
     
        public List<Animals> getAnimalsList() {
            return animalsList;
        }
     
        public void setAnimalsList(List<Animals> animalsList) {
            this.animalsList = animalsList;
        }
     
        public Map<String, Animals> map() {
            return animalsMap;
        }
     
        public Animals find(String id) {
            return animalsMap.get(id);
        }
     
        public void create(Animals animals) {
            em.persist(animals);
        }
     
        public void edit(Animals animals) {
            em.merge(animals);
        }
     
        public void remove(Animals animals) {
            em.remove(em.merge(animals));
        }
     
        public Animals find(Object id) {
            return em.find(Animals.class, id);
        }
     
        public List<Animals> findAll() {
            return em.createQuery("select object(o) from Animals as o").getResultList();
        }
    }
    Apres il suffit de créer un animal et ensuite d'appeler la méthode create(animal) et la ta base sera mise à jour.

Discussions similaires

  1. Erreur 5 : Accès refusé
    Par steca dans le forum Windows 7
    Réponses: 1
    Dernier message: 30/03/2010, 17h26
  2. Backup : "Erreur 5(Accès refusé.)"
    Par NejNej dans le forum Développement
    Réponses: 4
    Dernier message: 16/11/2009, 16h14
  3. Erreur 5 accès refusé
    Par misslovely dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 22/08/2008, 17h41
  4. 401 : accès refusé
    Par Promeneur dans le forum ASP.NET
    Réponses: 2
    Dernier message: 02/03/2007, 10h13
  5. erreur 1045: Accès refusé pour l'utilisateur mot de passe : OUI
    Par antrax2013 dans le forum SQL Procédural
    Réponses: 1
    Dernier message: 31/05/2006, 17h03

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