Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    44

    Hibernate - Struts

    Ciao a tutti,
    Stavo provando ad integrare hibernate e struts.
    Ho configurato il mio hibernate.cfg.xml, ho generato il plugin e caricato nello struts-config.xml, ho generato l'xml del mio schema e una classe che genera il SessionFactory.
    All'avvio del portale viene startato tutto correttamente:

    - Tiles definition factory loaded for module ''.
    - Hibernate 2.0 final
    - hibernate.properties not found
    - using CGLIB reflection optimizer
    - JVM proxy support: true
    - Mapping resource: com/file/bean/current.hbm.xml
    - Mapping class: com.file.bean.loginActionBean -> utenti
    - Configured SessionFactory: null
    - building session factory
    - Using dialect: net.sf.hibernate.dialect.MySQLDialect
    - Hibernate connection pool size: 20
    - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/myapp
    - connection properties: {user=xxx, password=xxx}
    - Use outer join fetching: true
    - Use scrollable result sets: true
    - JDBC 2 max batch size: 15
    - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactor y
    - echoing all SQL to stdout
    - no JDNI name configured
    - Query language substitutions: {}

    accedo alla mia pagina e mi viene fuori questo errore

    - Mapping file: webapps/StrutsBase/hibernate.cfg.xml
    - building session factory
    - No dialect set - using GenericDialect: The dialect was not set. Set the property hibernate.dialect.
    - Using dialect: net.sf.hibernate.dialect.GenericDialect
    - No connection properties specified - the user must supply JDBC connections
    - Use outer join fetching: false
    - Use scrollable result sets: false
    - no JDNI name configured
    - Query language substitutions: {}
    - Unhandled Exception thrown: class net.sf.hibernate.QueryException
    - Servlet.service() for servlet action threw exception

    ho provato a cambiargli il path del hibernate.cfg.xml ma mi dice che il path non è corretto quindi suppongo che lo legge ma non capisco perchè non setta i parametri, in tutto questo stò usando ant dove gli setto

    <target name="dialet">
    <property name="hibernate.dialect" value="yourdialet"/>
    <antcall target="hbm"/>
    </target>


    <target name="hbm" depends="compile">
    <taskdef
    name="hibernatedoclet"
    classname="xdoclet.modules.hibernate.HibernateDocl etTask"
    classpathref="libraries"
    />
    <hibernatedoclet
    destdir="${targetdir}"
    verbose="true">
    <fileset dir="${sourcedir}">
    <include name="**/*.java"/>
    </fileset>
    <hibernate version="2.0"/>
    <hibernatecfg
    dialect="${hibernate.dialect}"
    jdbcUrl="${hibernate.connection.url}"
    driver="${hibernate.connection.driver_class}"
    userName="${hibernate.connection.username}"
    password="${hibernate.connection.password}"
    showSql="true"
    version="2.0"
    />
    </hibernatedoclet>
    </target>
    oltre che ai soliti compile e clean.
    Se servono altre info non esitate a scrivermi grazie a tutti.

  2. #2
    Utente di HTML.it L'avatar di nether
    Registrato dal
    Dec 2006
    Messaggi
    376
    dall'errore sembra che il tuo file di configurazione di hibernate (hibernate.cfg.xml) non venga generato correttamente: in particolare, sembra che il file venga correttamente "trovato" al momento dell'inizializzazione della tua applicazione, ma al suo interno sembrano mancare alcune proprieta'.
    Prova a postare il contenuto del file hibernate.cfg.xml e vediamo.

    cmq domanda: hibernate e' alla versione 3.x (3.2) ora, devi per forza usare la 2.0?

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    44
    Allora uso la Hibernate 2.0 non uso la 3.x solo perchè ho trovato su internet + materiale sulla 2.0 quindi per comodità, cmq questo è l'haibernate.cfg.xml

    <?xml version="1.0" encoding="utf-8" ?>

    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

    <hibernate-configuration>

    <session-factory>

    <property name="hibernate.dialect">net.sf.hibernate.dialect. MySQLDialect</property>
    <property name="hibernate.connection.username">xxx</property>
    <property name="hibernate.connection.password">xxx</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost/myapp</property>
    <property name="hibernate.connection.driver_class">com.mysql .jdbc.Driver</property>
    <property name="show_sql">true</property>
    <property name="use_outer_join">true</property>
    <property name="transaction.factory_class">net.sf.hibernate. transaction.JDBCTransactionFactory</property>
    <property name="dbcp.minIdle">1</property>
    <property name="cache.use_query_cache">true</property>

    <property name="current_session_context_class">thread</property>
    <property name="bytecode.use_reflection_optimizer">false</property>
    <property name="current_session_context_class">net.sf.hibern ate.context.Thre=adLocalSessionContext</property>

    <mapping resource="com/file/bean/current.hbm.xml"/>
    </session-factory>
    </hibernate-configuration>

  4. #4
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    44
    Ah dimenticavo ti posto anche la classe che chiama il parser incriminato

    import net.sf.hibernate.*;
    import net.sf.hibernate.cfg.*;

    public class HibernateUtil {

    private static final SessionFactory sessionFactory;

    static {
    try {
    sessionFactory = new Configuration().addFile("webapps/StrutsBase/hibernate.cfg.xml").buildSessionFactory();
    } catch (Throwable ex) {
    System.err.println("Initial SessionFactory creation failed." + ex);
    throw new ExceptionInInitializerError(ex);
    }
    }

    public static SessionFactory getSessionFactory() {
    return sessionFactory;
    }

    }

  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    44
    ok risolto ho utilizzato hibernate 3.0 non mi ha dato più il problema precedente grazie a tutti

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.