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

Tomcat et TomEE Java Discussion :

[Tomcat / Hibernate] Erreur 500


Sujet :

Tomcat et TomEE Java

  1. #1
    Membre du Club
    Inscrit en
    Novembre 2008
    Messages
    122
    Détails du profil
    Informations forums :
    Inscription : Novembre 2008
    Messages : 122
    Points : 54
    Points
    54
    Par défaut [Tomcat / Hibernate] Erreur 500
    Bonjour,

    dans le cadre du developpement d'une application web, je rencontre le problème suivant lors de l'excecution :
    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
     
    Etat HTTP 500 -
     
    type Rapport d'exception
     
    message
     
    description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.
     
    exception
     
    javax.servlet.ServletException: L'exécution de la servlet a lancé une exception
    cause mère
     
    java.lang.ExceptionInInitializerError
    	util.HibernateUtil.<clinit>(HibernateUtil.java:19)
    	dao.DaoImpl.getProduitsParMC(DaoImpl.java:63)
    	web.ProduitAction.execute(ProduitAction.java:28)
    	org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
    	org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    cause mère
     
    org.hibernate.HibernateException: Hibernate.cfg.xml not found
    	org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
    	org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1265)
    	org.hibernate.cfg.Configuration.configure(Configuration.java:1287)
    	util.HibernateUtil.<clinit>(HibernateUtil.java:15)
    	dao.DaoImpl.getProduitsParMC(DaoImpl.java:63)
    	web.ProduitAction.execute(ProduitAction.java:28)
    	org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
    	org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/6.0.20.
    j'utilise hibernate 3, et tomcat 6, jdk1.6, eclipse ganymade

    ma classe action :
    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 web;
     
    import java.util.List;
     
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
     
    import dao.DaoImpl;
    import dao.Produit;
     
    public class ProduitAction extends Action{
     
    	@Override
    	public ActionForward execute(ActionMapping mapping, ActionForm form,
    			HttpServletRequest request, HttpServletResponse response)
    			throws Exception {
     
     
    		ProduitForm pf=(ProduitForm) form;
    		DaoImpl daos= new DaoImpl();
    		//String mcP = pf.getMotCle();
    		//List<Produit> prods = daos.getProduitsParMC(mcP);
    		List<Produit> prods = daos.getProduitsParMC(pf.getMotCle());
    		pf.setProduits(prods);
    		return (mapping.findForward("vueProduits"));
    	}
     
    }
    ma classe form
    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
     
    package web;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import org.apache.struts.action.ActionForm;
     
    import dao.Produit;
     
    public class ProduitForm extends ActionForm {
     
    	private String motCle;
    	private List<Produit> produits = new ArrayList<Produit>();
     
    	public String getMotCle() {
    		return motCle;
    	}
    	public void setMotCle(String motCle) {
    		this.motCle = motCle;
    	}
    	public List<Produit> getProduits() {
    		return produits;
    	}
    	public void setProduits(List<Produit> produits) {
    		this.produits = produits;
    	}
     
     
    }
    le fichier struts.config
    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
     
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
              "http://struts.apache.org/dtds/struts-config_1_2.dtd">
     
    <struts-config>
     <form-beans>
    	<form-bean name="pf" type="web.ProduitForm"/>
     </form-beans>
     <global-forwards>
      <forward name="vueProduits" path="/Vues/Produits.jsp"/>
     </global-forwards>
     <action-mappings>
    	<action 
    	 path="/catal" 
    	 name="pf" 
    	 type="web.ProduitAction" 
    	 scope="request"
    	 />
     </action-mappings>
     <message-resources parameter="ApplicationResources"/>
    </struts-config>
    le fichier web.xml
    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
     
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
      <display-name>Struts Examples Application</display-name>
      <!-- Standard Action Servlet Configuration (with debugging) -->
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>2</param-value>
        </init-param>
        <init-param>
          <param-name>detail</param-name>
          <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
      </servlet>
      <!-- Standard Action Servlet Mapping -->
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
     
      <!-- Struts Tag Library Descriptors -->
      <taglib>
        <taglib-uri>/tags/struts-bean</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-logic</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-nested</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
      </taglib>
     
    </web-app>
    quelq'un aura t il une idée svp ?

  2. #2
    Membre expérimenté
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2004
    Messages
    1 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 184
    Points : 1 745
    Points
    1 745
    Par défaut
    Bonjour,
    Le message est clair :

    org.hibernate.HibernateException: Hibernate.cfg.xml not found

  3. #3
    Membre du Club
    Inscrit en
    Novembre 2008
    Messages
    122
    Détails du profil
    Informations forums :
    Inscription : Novembre 2008
    Messages : 122
    Points : 54
    Points
    54
    Par défaut
    Citation Envoyé par Mathieu.J Voir le message
    Bonjour,
    Le message est clair :
    ==========
    oui mais la classe existe bien..
    voila le code de la classe :
    hibenate.util :
    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
    package util;
     
    import org.hibernate.*;
    import org.hibernate.cfg.*;
     
    public class HibernateUtil {
        public static final SessionFactory sessionFactory;
     
        static {
            try {
                // Création de la SessionFactory à partir de hibernate.cfg.xml
            	//Hibernateutil est un singleton (design pattern), il vous garanti d'avoir un seul objet(hibernate util)dans toute votre application
            	//(en realité il est créer une seul fois(1er appel) méme s'il est charger bcp de fois,
            	//un singleton est une classe dans laquelle il y a un model qui vous garantie qu'il y a qu'un seul objet qui sera créer (o premier appel de la classe)
                sessionFactory = new Configuration().configure("Hibernate.cfg.xml").buildSessionFactory();
            } catch (Throwable ex) {
                // Make sure you log the exception, as it might be swallowed
                System.err.println("Initial SessionFactory creation failed." + ex);
                throw new ExceptionInInitializerError(ex);
            }
        }
     
       // public static final ThreadLocal session = new ThreadLocal();
     
        public static SessionFactory getSessionFactory() {
            return sessionFactory;
        }
    }

    fichier .hbm.xml
    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
     
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Generated 8 mars 2013 14:53:52 by Hibernate Tools 3.4.0.CR1 -->
    <hibernate-mapping>
        <class name="dao.Produit" table="PRODUITS">
            <id name="idProduit" type="java.lang.Long">
                <column name="ID_PRODUIT" />
                <generator class="native" />
            </id>
            <property name="nom" type="java.lang.String" length="20">
                <column name="NOM" />
            </property>
            <property name="prix" type="double">
                <column name="PRIX" />
            </property>
            <property name="quantite" type="int">
                <column name="QUANTITE" />
            </property>
        </class>
    </hibernate-mapping>

  4. #4
    Membre confirmé
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Octobre 2008
    Messages
    380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2008
    Messages : 380
    Points : 480
    Points
    480
    Par défaut
    Bonjour,

    C'est le fichier 'Hibernate.cfg.xml' qui n'est pas trouvé lors de l'appel. Est ce qu'il existe et ou est il placé?

    A+.

  5. #5
    Membre du Club
    Inscrit en
    Novembre 2008
    Messages
    122
    Détails du profil
    Informations forums :
    Inscription : Novembre 2008
    Messages : 122
    Points : 54
    Points
    54
    Par défaut
    Citation Envoyé par eric39 Voir le message
    Bonjour,

    C'est le fichier 'Hibernate.cfg.xml' qui n'est pas trouvé lors de l'appel. Est ce qu'il existe et ou est il placé?

    A+.
    il existe dans la racine : src/...
    ---
    G recréer un nouveau fichier avec le mm nom et le mm contenu..et ca marche..

    c'est bizarre mais ca marche

    merci pr votre aide

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Tomcat 6] Erreur 500 - semble avoir conservé paramètres
    Par CinePhil dans le forum Tomcat et TomEE
    Réponses: 1
    Dernier message: 02/12/2014, 15h04
  2. [Tomcat 6] Erreur 500 Jasper
    Par CinePhil dans le forum Tomcat et TomEE
    Réponses: 2
    Dernier message: 07/11/2014, 13h15
  3. BlazeDS + Tomcat + Hibernate = erreur au demarrage
    Par k-koo dans le forum Frameworks Web
    Réponses: 0
    Dernier message: 22/10/2008, 19h11
  4. [Tomcat] erreur 500 jsp servlet
    Par juanqui dans le forum Tomcat et TomEE
    Réponses: 13
    Dernier message: 23/02/2006, 11h45
  5. [tomcat] Erreur 500 à l'appel de la servlet
    Par Kyti dans le forum Tomcat et TomEE
    Réponses: 26
    Dernier message: 06/04/2005, 09h37

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