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

Spring Java Discussion :

HibernateDaoSupport getHibernateTemplate retourne null [Data]


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Invité
    Invité(e)
    Par défaut HibernateDaoSupport getHibernateTemplate retourne null
    Bonjour,

    Je tente (vainement) de configurer un dao avec Spring et Hibernate. Mais lorsque je demande le HibernateTemplate je reçoit un null :

    Voci mon dao :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    public class SpringHibernateStudentDao extends HibernateDaoSupport implements StudentDao {
     
        public Student getStudent(int id) throws DataAccessException {
            HibernateTemplate hibtemp = getHibernateTemplate();
            System.out.println("HibernateTemplate : " + hibtemp);
            Student student = (Student) hibtemp.get(Student.class, id);
            System.out.println("Student : " + student);
            return student;
        }
     
    }
    Mon manager, service :
    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
    public class StudentManager {
     
        private DAOFactory daoFactory;
     
        public StudentManager(DAOFactory daoFactory) {
            this.daoFactory = daoFactory;
        }
     
        public Student getStudent(int id) {
            Student student = daoFactory.getStudentDao().getStudent(id);
            System.out.println("Student : " + student);
            return student;
        }
     
    }
    Mon applicationContext.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
    ...
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName"><value>org.postgresql.Driver</value></property>
            <property name="url"><value>jdbc:postgresql://localhost:5432/MADB</value></property>
            <property name="username"><value>user</value></property>
            <property name="password"><value>admin</value></property>
        </bean>
     
        <!-- Hibernate SessionFactory -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource"><ref local="dataSource"/></property>
            <property name="mappingResources">
                <list>
                    <value>Student.hbm.xml</value>
                </list>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                    <prop key="hibernate.hbm2ddl.auto">create</prop>
                </props>
            </property>
        </bean>
     
        <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
        <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory"><ref local="sessionFactory"/></property>
        </bean>
     
        <bean id="studentDAO" class="dao.impl.spring.hibernate.SpringHibernateStudentDao">
            <property name="sessionFactory"><ref local="sessionFactory"/></property>
        </bean>
     
        <bean id="daoFactory" class="dao.impl.spring.hibernate.SpringHibernateDaoFactory" />
     
        <bean id="studentManager" class="manager.StudentManager">
            <constructor-arg><ref bean="daoFactory" /></constructor-arg>
        </bean>
    ...
    Et ma classe d'entrée :
    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
     
    public class StudentManagerTest {
     
        /** Creates a new instance of StudenteManagerTest */
        public StudentManagerTest() {
        }
     
        public static void main(String[] args) {
     
            ApplicationContext ctx = 
                    new FileSystemXmlApplicationContext("applicationContext.xml");
            StudentManager mngr = (StudentManager) ctx.getBean("studentManager");
     
            System.out.println("Student Manager :" + mngr);
            mngr.getStudent(3);
     
        }
    }
    et le résultat à la console (les logs d'hibrenate ne me sortent aucunes erreurs, que des TRACE, DEBUG et INFO) :
    Student Manager :manager.StudentManager@5e222e
    HibernateTemplate : null
    Exception in thread "main" java.lang.NullPointerException
    Je soupçone le fait de ne jamais injecter mon "HibernateTemplate" mais dans tous les fichiers de config que je trouve, je en vois jamais cette injection et je ne sais pas comment la créer.

    Merci de m'éclairer
    Dernière modification par Robin56 ; 05/08/2013 à 21h35. Motif: Ajout du préfixe

  2. #2
    Rédacteur
    Avatar de Hikage
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    1 177
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 177
    Par défaut
    C'est assez bizarre en effet, apparement, l'HibernateTemplate est crée dans le setter de la sessionFactory de HibernateDaoSupport...

    Tu sais vérifier que la sessionFacotry est bien différente de null ? ( normaleme,nt oui vu que tu l'injecte mais bon ... )
    Hikage
    SCJP / SCWCD & SCWSJD Certified / Spring Framework Certified
    [Personal Web] [CV]

    F.A.Q Spring Framework - Participez !

  3. #3
    Invité
    Invité(e)
    Par défaut
    Je viens de modifier mon dao :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    public class SpringHibernateStudentDao extends HibernateDaoSupport implements StudentDao {
     
        public Student getStudent(int id) throws DataAccessException {
            System.out.println("Session factory :" + getSessionFactory());
            HibernateTemplate hibtemp = getHibernateTemplate();
            System.out.println("HibernateTemplate : " + hibtemp);
            Student student = (Student) hibtemp.get(Student.class, id);
            System.out.println("Student : " + student);
            return student;
        }
    ...
    mais le résultat ne vas te plaire :
    Student Manager :manager.StudentManager@5e222e
    Session factory :null
    HibernateTemplate : null
    Note : Je travaille avec NetBeans et j'ai divisé cela en plusieurs sous projets :
    - MoiCommons (Beans généraux : Personne, Contact,..)
    - ProjetCommons (Student)
    - ProjetDao (StudentDao,..)
    - ProjetServices (StudentManager, et Classe de test)
    Toutes mes archives sont présentes dans ProjetServices (sur lequel je fais mes tests). Lorsque j'ai voulu rajouter getSessionFactiry(), j'ai du également ajouter la jar d'hibernate dans ProjetDao. Je suppose que ça n'a pas d'importance, c'est juste des délires de NteBeans mais bon..
    Edit : Je viens de fusionner ProjetDao avec ProjetService et ça ne change pas. Donc ce n'est pa sle fait d'avoir de multiples sous projets
    Dernière modification par Invité ; 21/11/2007 à 15h44.

  4. #4
    Rédacteur
    Avatar de Hikage
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    1 177
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 177
    Par défaut
    Heu vi .. alors la, j'ai du mal a comprendre ce qu'il se passe ...

    As-tu possibilité de configurer log4j, et de mettre le niveau pour les classe org.spring à DEBUG voir TRACE?

    Histoire de voir ce qu'il configure
    Hikage
    SCJP / SCWCD & SCWSJD Certified / Spring Framework Certified
    [Personal Web] [CV]

    F.A.Q Spring Framework - Participez !

  5. #5
    Invité
    Invité(e)
    Par défaut
    Waip :

    run:
    INFO [main] org.springframework.context.support.FileSystemXmlApplicationContext - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@126e85f: display name [org.springframework.context.support.FileSystemXmlApplicationContext@126e85f]; startup date [Wed Nov 21 16:09:32 CET 2007]; root of context hierarchy
    DEBUG [main] org.springframework.util.ClassUtils - Class [edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap] or one of its dependencies is not present: java.lang.ClassNotFoundException: edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap
    INFO [main] org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices\applicationContext.xml]
    DEBUG [main] org.springframework.beans.factory.xml.DefaultDocumentLoader - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
    DEBUG [main] org.springframework.beans.factory.xml.PluggableSchemaResolver - Loading schema mappings from [META-INF/spring.schemas]
    DEBUG [main] org.springframework.beans.factory.xml.PluggableSchemaResolver - Loaded schema mappings: {http://www.springframework.org/schem...g-lang-2.5.xsd, http://www.springframework.org/schem...g-lang-2.5.xsd, http://www.springframework.org/schem...ontext-2.5.xsd, http://www.springframework.org/schem...ng-jms-2.5.xsd, http://www.springframework.org/schem...ontext-2.5.xsd, http://www.springframework.org/schem...ng-aop-2.5.xsd, http://www.springframework.org/schem...g-util-2.0.xsd, http://www.springframework.org/schem...g-util-2.5.xsd, http://www.springframework.org/schem...g-tool-2.0.xsd, http://www.springframework.org/schem...ing-tx-2.0.xsd, http://www.springframework.org/schem...g-tool-2.5.xsd, http://www.springframework.org/schem...ing-tx-2.5.xsd, http://www.springframework.org/schem...-beans-2.0.xsd, http://www.springframework.org/schem...ng-jms-2.5.xsd, http://www.springframework.org/schem...-beans-2.5.xsd, http://www.springframework.org/schem...-beans-2.5.xsd, http://www.springframework.org/schem...ng-jee-2.5.xsd, http://www.springframework.org/schem...g-tool-2.5.xsd, http://www.springframework.org/schem...ing-tx-2.5.xsd, http://www.springframework.org/schem...ng-jee-2.0.xsd, http://www.springframework.org/schem...ng-aop-2.0.xsd, http://www.springframework.org/schem...ng-aop-2.5.xsd, http://www.springframework.org/schem...ng-jee-2.5.xsd, http://www.springframework.org/schem...g-lang-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd}
    DEBUG [main] org.springframework.beans.factory.xml.PluggableSchemaResolver - Found XML schema [http://www.springframework.org/schem...ing-beans.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-2.5.xsd
    DEBUG [main] org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader - Loading bean definitions
    DEBUG [main] org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loaded 6 bean definitions from location pattern [applicationContext.xml]
    INFO [main] org.springframework.context.support.FileSystemXmlApplicationContext - Bean factory for application context [org.springframework.context.support.FileSystemXmlApplicationContext@126e85f]: org.springframework.beans.factory.support.DefaultListableBeanFactory@4f9fdc
    DEBUG [main] org.springframework.context.support.FileSystemXmlApplicationContext - 6 beans defined in org.springframework.context.support.FileSystemXmlApplicationContext@126e85f: display name [org.springframework.context.support.FileSystemXmlApplicationContext@126e85f]; startup date [Wed Nov 21 16:09:32 CET 2007]; root of context hierarchy
    DEBUG [main] org.springframework.context.support.FileSystemXmlApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@1385660]
    DEBUG [main] org.springframework.context.support.FileSystemXmlApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@136a43c]
    INFO [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4f9fdc: defining beans [dataSource,sessionFactory,transactionManager,studentDAO,daoFactory,studentManager]; root of factory hierarchy
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'dataSource'
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'dataSource' with merged definition [Root bean: class [org.springframework.jdbc.datasource.DriverManagerDataSource]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices\applicationContext.xml]]
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'dataSource' to allow for resolving potential circular references
    INFO [main] org.springframework.jdbc.datasource.DriverManagerDataSource - Loaded JDBC driver: org.postgresql.Driver
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'sessionFactory'
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'sessionFactory' with merged definition [Root bean: class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices\applicationContext.xml]]
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'sessionFactory' to allow for resolving potential circular references
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'dataSource'
    INFO [main] org.hibernate.cfg.Environment - Hibernate 3.2.5
    INFO [main] org.hibernate.cfg.Environment - hibernate.properties not found
    INFO [main] org.hibernate.cfg.Environment - Bytecode provider name : cglib
    INFO [main] org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
    DEBUG [main] org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hib...pping-3.0.dtd]
    DEBUG [main] org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
    DEBUG [main] org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hib...pping-3.0.dtd] in classpath
    INFO [main] org.hibernate.cfg.HbmBinder - Mapping class: be.gervaisb.sics.commons.beans.Student -> students
    DEBUG [main] org.hibernate.cfg.HbmBinder - Mapped property: id -> stuid
    DEBUG [main] org.hibernate.cfg.HbmBinder - Mapped property: firstName -> stuname
    DEBUG [main] org.hibernate.cfg.HbmBinder - Mapped property: lastName -> stulastname
    INFO [main] org.springframework.orm.hibernate3.LocalSessionFactoryBean - Building new Hibernate SessionFactory
    DEBUG [main] org.hibernate.cfg.Configuration - Preparing to build session factory with filters : {}
    DEBUG [main] org.hibernate.cfg.Configuration - processing extends queue
    DEBUG [main] org.hibernate.cfg.Configuration - processing collection mappings
    DEBUG [main] org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
    DEBUG [main] org.hibernate.cfg.Configuration - processing association property references
    DEBUG [main] org.hibernate.cfg.Configuration - processing foreign key constraints
    INFO [main] org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
    DEBUG [main] org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC Connection to [jdbc:postgresql://localhost:5432/SICS]
    INFO [main] org.hibernate.cfg.SettingsFactory - RDBMS: PostgreSQL, version: 8.2.5
    INFO [main] org.hibernate.cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 505)
    INFO [main] org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect
    INFO [main] org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
    INFO [main] org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    INFO [main] org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
    INFO [main] org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
    DEBUG [main] org.hibernate.cfg.SettingsFactory - Wrap result sets: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Connection release mode: on_close
    INFO [main] org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
    INFO [main] org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    INFO [main] org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
    INFO [main] org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
    INFO [main] org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Query cache: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.NoCacheProvider
    INFO [main] org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
    TRACE [main] org.hibernate.exception.SQLExceptionConverterFactory - Using dialect defined converter
    INFO [main] org.hibernate.cfg.SettingsFactory - Statistics: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
    INFO [main] org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
    INFO [main] org.hibernate.cfg.SettingsFactory - Named query checking : enabled
    INFO [main] org.hibernate.impl.SessionFactoryImpl - building session factory
    DEBUG [main] org.hibernate.impl.SessionFactoryImpl - Session factory constructed with filter configurations : {}
    DEBUG [main] org.hibernate.impl.SessionFactoryImpl - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\Java\1.5\jdk1.5.0_08\jre\bin, java.vm.version=1.5.0_08-b03, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=BE, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices, java.runtime.version=1.5.0_08-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hibernate.current_session_context_class=org.springframework.orm.hibernate3.SpringSessionContext, java.endorsed.dirs=C:\Java\1.5\jdk1.5.0_08\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\Gervais\LOCALS~1\Temp\, line.separator=
    , java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\Java\1.5\jdk1.5.0_08\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\PostgreSQL\8.2\bin;C:\Program Files\Subversion\bin, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\Gervais, user.timezone=Europe/Paris, hibernate.connection.release_mode=on_close, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.5, java.class.path=C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\GervaisbCommons\dist\GervaisbCommons.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\SicsCommons\dist\SicsCommons.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\Databases\PostgresSQL\postgresql-8.2-505.jdbc3.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\Spring\spring-framework-2.5-with-dependencies\spring-framework-2.5\dist\spring.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\hibernate-3.2.5.ga\hibernate-3.2\hibernate3.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\Spring\spring-framework-2.5-with-dependencies\spring-framework-2.5\lib\dom4j\dom4j-1.6.1.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\Jta\jta-1_1-classes.zip;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\commons-collections-3.2\commons-collections-3.2.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\Spring\spring-framework-2.5-with-dependencies\spring-framework-2.5\lib\cglib\cglib-nodep-2.1_3.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\Log4J\commons-logging-1.1\commons-logging-1.1.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\Libs\Log4J\apache-log4j-1.2.15\log4j-1.2.15.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\SicsDao\dist\SchoolManagerDao.jar;C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices\build\classes, user.name=Gervais, hibernate.bytecode.use_reflection_optimizer=false, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\Java\1.5\jdk1.5.0_08\jre, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, java.specification.vendor=Sun Microsystems Inc., user.language=fr, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.5.0_08, java.ext.dirs=C:\Java\1.5\jdk1.5.0_08\jre\lib\ext, sun.boot.class.path=C:\Java\1.5\jdk1.5.0_08\jre\lib\rt.jar;C:\Java\1.5\jdk1.5.0_08\jre\lib\i18n.jar;C:\Java\1.5\jdk1.5.0_08\jre\lib\sunrsasign.jar;C:\Java\1.5\jdk1.5.0_08\jre\lib\jsse.jar;C:\Java\1.5\jdk1.5.0_08\jre\lib\jce.jar;C:\Java\1.5\jdk1.5.0_08\jre\lib\charsets.jar;C:\Java\1.5\jdk1.5.0_08\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.hbm2ddl.auto=create, hibernate.connection.provider_class=org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
    INFO [main] org.hibernate.tuple.PojoInstantiator - no default (no-argument) constructor for class: be.gervaisb.sics.commons.beans.Student (class must be instantiated by Interceptor)
    DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Static SQL for entity: be.gervaisb.sics.commons.beans.Student
    DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Version select: select stuid from students where stuid =?
    DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Snapshot select: select student_.stuid, student_.stuname as stuname0_, student_.stulastname as stulastn3_0_ from students student_ where student_.stuid=?
    DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Insert 0: insert into students (stuname, stulastname, stuid) values (?, ?, ?)
    DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Update 0: update students set stuname=?, stulastname=? where stuid=?
    DEBUG [main] org.hibernate.persister.entity.AbstractEntityPersister - Delete 0: delete from students where stuid=?
    DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity be.gervaisb.sics.commons.beans.Student: select student0_.stuid as stuid0_0_, student0_.stuname as stuname0_0_, student0_.stulastname as stulastn3_0_0_ from students student0_ where student0_.stuid=?
    DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity be.gervaisb.sics.commons.beans.Student: select student0_.stuid as stuid0_0_, student0_.stuname as stuname0_0_, student0_.stulastname as stulastn3_0_0_ from students student0_ where student0_.stuid=?
    DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity be.gervaisb.sics.commons.beans.Student: select student0_.stuid as stuid0_0_, student0_.stuname as stuname0_0_, student0_.stulastname as stulastn3_0_0_ from students student0_ where student0_.stuid=? for update
    DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity be.gervaisb.sics.commons.beans.Student: select student0_.stuid as stuid0_0_, student0_.stuname as stuname0_0_, student0_.stulastname as stulastn3_0_0_ from students student0_ where student0_.stuid=? for update
    DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for entity be.gervaisb.sics.commons.beans.Student: select student0_.stuid as stuid0_0_, student0_.stuname as stuname0_0_, student0_.stulastname as stulastn3_0_0_ from students student0_ where student0_.stuid=? for update
    DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for action ACTION_MERGE on entity be.gervaisb.sics.commons.beans.Student: select student0_.stuid as stuid0_0_, student0_.stuname as stuname0_0_, student0_.stulastname as stulastn3_0_0_ from students student0_ where student0_.stuid=?
    DEBUG [main] org.hibernate.loader.entity.EntityLoader - Static select for action ACTION_REFRESH on entity be.gervaisb.sics.commons.beans.Student: select student0_.stuid as stuid0_0_, student0_.stuname as stuname0_0_, student0_.stulastname as stulastn3_0_0_ from students student0_ where student0_.stuid=?
    DEBUG [main] org.hibernate.impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
    DEBUG [main] org.hibernate.impl.SessionFactoryObjectFactory - registered: 2c90858a1662c1c1011662c1c2d50000 (unnamed)
    INFO [main] org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
    DEBUG [main] org.hibernate.impl.SessionFactoryImpl - instantiated session factory
    DEBUG [main] org.hibernate.cfg.Configuration - processing extends queue
    DEBUG [main] org.hibernate.cfg.Configuration - processing collection mappings
    DEBUG [main] org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
    DEBUG [main] org.hibernate.cfg.Configuration - processing association property references
    DEBUG [main] org.hibernate.cfg.Configuration - processing foreign key constraints
    DEBUG [main] org.hibernate.cfg.Configuration - processing extends queue
    DEBUG [main] org.hibernate.cfg.Configuration - processing collection mappings
    DEBUG [main] org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
    DEBUG [main] org.hibernate.cfg.Configuration - processing association property references
    DEBUG [main] org.hibernate.cfg.Configuration - processing foreign key constraints
    INFO [main] org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
    DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport - import file not found: /import.sql
    INFO [main] org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
    DEBUG [main] org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC Connection to [jdbc:postgresql://localhost:5432/SICS]
    DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport - drop table students
    DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport - drop sequence hibernate_sequence
    DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport - create table students (stuid int4 not null, stuname varchar(255), stulastname varchar(255), primary key (stuid))
    DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport - create sequence hibernate_sequence
    INFO [main] org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
    DEBUG [main] org.hibernate.impl.SessionFactoryImpl - Checking 0 named HQL queries
    DEBUG [main] org.hibernate.impl.SessionFactoryImpl - Checking 0 named SQL queries
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'transactionManager'
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'transactionManager' with merged definition [Root bean: class [org.springframework.orm.hibernate3.HibernateTransactionManager]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices\applicationContext.xml]]
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'transactionManager' to allow for resolving potential circular references
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'sessionFactory'
    INFO [main] org.springframework.orm.hibernate3.HibernateTransactionManager - Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@118958e] of Hibernate SessionFactory for HibernateTransactionManager
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'studentDAO'
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'studentDAO' with merged definition [Root bean: class [be.gervaisb.sics.dao.impl.spring.hibernate.SpringHibernateStudentDao]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices\applicationContext.xml]]
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'studentDAO' to allow for resolving potential circular references
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'sessionFactory'
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'daoFactory'
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'daoFactory' with merged definition [Root bean: class [be.gervaisb.sics.dao.impl.spring.hibernate.SpringHibernateDaoFactory]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices\applicationContext.xml]]
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'daoFactory' to allow for resolving potential circular references
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'studentManager'
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'studentManager' with merged definition [Root bean: class [be.gervaisb.sics.manager.StudentManager]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\Documents and Settings\Gervais\My Documents\My Projects\SicsServices\applicationContext.xml]]
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'daoFactory'
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'studentManager' to allow for resolving potential circular references
    Exception in thread "main" java.lang.NullPointerException
    at be.gervaisb.sics.dao.impl.spring.hibernate.SpringHibernateStudentDao.getStudent(SpringHibernateStudentDao.java:22)
    at be.gervaisb.sics.manager.StudentManager.getStudent(StudentManager.java:24)
    at tests.StudentManagerTest.main(StudentManagerTest.java:41)
    DEBUG [main] org.springframework.context.support.FileSystemXmlApplicationContext - Publishing event in context [org.springframework.context.support.FileSystemXmlApplicationContext@126e85f]: org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.FileSystemXmlApplicationContext@126e85f: display name [org.springframework.context.support.FileSystemXmlApplicationContext@126e85f]; startup date [Wed Nov 21 16:09:32 CET 2007]; root of context hierarchy]
    DEBUG [main] org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'studentManager'
    Student Manager :be.gervaisb.sics.manager.StudentManager@aa0877
    DaoFactiry : be.gervaisb.sics.dao.impl.spring.hibernate.SpringHibernateDaoFactory@111ded2
    Session factory :null
    HibernateTemplate : null

  6. #6
    Rédacteur
    Avatar de Hikage
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    1 177
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 177
    Par défaut
    MM j'ai une piste.

    Montre le code de ton DaoFactory :p

    Car tu récupere le StudentDao par la, mais si c'est la DaoFactory qui te retourne le StudentDao sans passer par l'ApplicationContext, ce n'est pas Spring qui gere, donc la SessionFactory n'est simplement pas injectée
    Hikage
    SCJP / SCWCD & SCWSJD Certified / Spring Framework Certified
    [Personal Web] [CV]

    F.A.Q Spring Framework - Participez !

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

Discussions similaires

  1. Findcontrol retourne null
    Par Kiwi_violet dans le forum ASP.NET
    Réponses: 1
    Dernier message: 13/04/2007, 12h21
  2. TTF_OpenFont() retournant NULL
    Par FabaCoeur dans le forum SDL
    Réponses: 4
    Dernier message: 11/04/2007, 16h30
  3. GetDC retourne NULL Oo
    Par Groove dans le forum OpenGL
    Réponses: 3
    Dernier message: 02/03/2007, 17h46
  4. Réponses: 3
    Dernier message: 02/03/2007, 11h41
  5. opérateur + dans SELECT retourne null ?
    Par david_chardonnet dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 19/01/2007, 10h47

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