-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Error when SessionFactory is initialized
PostPosted: Wed Oct 07, 2009 5:36 pm 
Newbie

Joined: Wed Oct 07, 2009 5:10 pm
Posts: 3
Hi all,

I'm trying to develop a Hibernate's application and I have the next execution error when I run the program:

Code:
16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA
19 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
24 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
29 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
123 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
125 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
246 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : mapeos/AppUser.hbm.xml
332 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: erpymesModel.UsersMg.AppUser -> STD_APPUSERS
360 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
446 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
447 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 1
448 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
459 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/erpymes_desarrollo
460 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=ERPYMES, password=****}
883 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.1.39-community
883 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.7 ( Revision: ${svn.Revision} )
917 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQL5Dialect
923 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
925 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
925 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
925 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
925 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
925 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
926 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
926 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
927 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
928 [main] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
928 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
928 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
929 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
929 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
930 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
935 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
936 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
936 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
936 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
936 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
941 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
941 [main] INFO org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge - Cache provider: org.hibernate.cache.NoCacheProvider
941 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
941 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
948 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
949 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
949 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
949 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
949 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
1010 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
Ocurrió un error en la inicialización de la SessionFactory: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
Exception in thread "main" java.lang.NullPointerException


I had included this libraries:
    hibernate3.jar
    antlr-2.7.6.jar
    commons-collections-3.1.jar
    dom4j-1.6.1.jar
    jta-1.1.jar
    javassist-3.4.ga.jar
    slf4j-api-1.5.8.jar
    slf4j-simple-1.5.8.jar

I read on Internet that the problem is solved including the javassist library, but I try to include some differents versions and the result is the same. I think that one (or more) of these libraries generates the error, but I don't know what is it.

How can I solve this problem?

Thank you very much.


Top
 Profile  
 
 Post subject: Re: Error when SessionFactory is initialized
PostPosted: Wed Oct 07, 2009 7:40 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi javi.jaz1984,

unfortunately, you cut off the log output when it becomes interesting. Please post the whole stack trace of your NPE.

CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


Top
 Profile  
 
 Post subject: Re: Error when SessionFactory is initialized
PostPosted: Thu Oct 08, 2009 2:20 pm 
Newbie

Joined: Wed Oct 07, 2009 5:10 pm
Posts: 3
Hi Froestel,

First, I want to thank you for your prompt response.

I post here the complet trace, but it doesn't give me any interesting information:

Code:
37 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA
40 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
47 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
55 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
150 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
150 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
305 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : mapeos/AppUser.hbm.xml
410 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: erpymesModel.UsersMg.AppUser -> STD_APPUSERS
442 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
517 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
518 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 1
518 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
541 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/erpymes_desarrollo
541 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=ERPYMES, password=****}
1801 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.1.39-community
1801 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.7 ( Revision: ${svn.Revision} )
1835 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQL5Dialect
1841 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
1844 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
1844 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
1844 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
1844 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
1844 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
1845 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
1845 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
1845 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
1847 [main] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
1847 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
1848 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
1848 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
1849 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
1849 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
1855 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
1855 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
1855 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
1855 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
1855 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
1860 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
1861 [main] INFO org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge - Cache provider: org.hibernate.cache.NoCacheProvider
1861 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
1861 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
1868 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
1869 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
1869 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
1869 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
1869 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
1950 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
Ocurrió un error en la inicialización de la SessionFactory: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
Exception in thread "main" java.lang.NullPointerException
        at erpymesModel.UsersMg.MgAppUser.addUser(MgAppUser.java:76)
        at erpymesModel.UsersMg.MgAppUser.main(MgAppUser.java:114)
Java Result: 1


I also post the source code related with Hibernate's library.

Code:
    private Session _sesion;
    private Transaction _tx; 

   
    private void iniciaOperacion() throws HibernateException
    {
        _sesion = HibernateUtil.getSessionFactory().openSession();
        _tx = _sesion.beginTransaction();
    }
   
    private void manejaExcepcion(HibernateException he) throws HibernateException
    {
        _tx.rollback();
        throw new HibernateException("Ocurrió un error en la capa de acceso a datos", he);
    }

....

    public int addUser(String userName, String name, String idPerson,
            String idClient, String password, String passwordRepeat,
            String description, boolean isLocked, Date dateStart, Date dateEnd){
        int result = 1;
        //TO DO
        AppUser newUser = new AppUser(userName, name, password,
            description, dateStart, dateEnd, isLocked, idPerson, idClient);
                   
                try
                {
                    iniciaOperacion();
                    result = (Integer) _sesion.save(newUser);
                    _tx.commit();
                } catch (HibernateException he)
                {
                    manejaExcepcion(he);
                    throw he;
                } finally
                {
                    _sesion.close();
                } 
       
        return result;       
    }

...

//Main invocation
mg.addUser("usuario","nombre","id","idC","pass","pass","desc",false,dt,dt);


Finally, I post my hibernate's config file and the .hbm file related with my class.

hibernate.cfg.xml:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   
    <session-factory>
        <!-- Database connection settings -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost/erpymes_desarrollo</property>
        <property name="connection.username">ERPYMES</property>
        <property name="connection.password">ERPYMES</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">create-drop</property>

        <mapping resource="mapeos/AppUser.hbm.xml" />
    </session-factory>

</hibernate-configuration>



AppUser.hbm.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
   <class name="erpymesModel.UsersMg.AppUser" table="STD_APPUSERS">
      <id name="userName" column="STD_USERNAME" unsaved-value="-1">
                    <generator class="assigned"/>
                </id>
      <property name="_name" column="STD_NAME" not-null="true"/>
      <property name="_password" column="STD_PASSWORD" not-null="true"/>
      <property name="_description" column="STD_DESCRIPTION"/>
      <property name="_dtStart" type="date" column="STD_DT_START" not-null="true"/>
      <property name="_dtEnd" type="date" column="STD_DT_END"/>
      <property name="_isLocked" column="STD_IS_LOCKED" not-null="true"/>               
   </class>
</hibernate-mapping>



Thank you very much.


Top
 Profile  
 
 Post subject: Re: Error when SessionFactory is initialized
PostPosted: Sat Oct 10, 2009 3:39 am 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi javi.jaz1984,

the problem does not look like it is in your code. Building the SessionFactory fails, I guess the NPE comes from line
Code:
iniciaOperacion();
in public int addUser(...).

Could you probably post the library files you have on your classpath.

CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


Top
 Profile  
 
 Post subject: Re: Error when SessionFactory is initialized
PostPosted: Sat Oct 10, 2009 8:09 am 
Newbie

Joined: Wed Oct 07, 2009 5:10 pm
Posts: 3
Hi Froestel,

I have found the error. If I quit the Try-catch instruction, the program returns a complete error trace and it says that the problem was in "_name" getter operation.

My atribute was named as _name, and so Hibernate doesn't find its getter method. When I renamed the attribute as name (without "_" character) the program worked fine.

Although I corrected the program, I wonder know how Hibernate searchs the getter methods when the attributes begin with "_" character.

Thank you very much.


Top
 Profile  
 
 Post subject: Re: Error when SessionFactory is initialized
PostPosted: Sun Oct 11, 2009 4:18 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi javi.jaz1984,

you usually don't start your field names with an underscore, do you? I think Hibernate sticks to the Java Beans convention on accessor methods, i.e. if the filed name is name then the accessors are getName() and setName(). Starting with an underscore might, therefore, cause some trouble.

CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.