title: Java: hibernate in web app - unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
body: <p>I am struggling strange problem with Hibernate in web application, although I don't encounter it in test standalone application.</p>
  
  <p><em>faces-config.xml</em></p>
  
  <pre><code>    &lt;managed-bean&gt;
          &lt;managed-bean-name&gt;businessUserData&lt;/managed-bean-name&gt;
          &lt;managed-bean-class&gt;org.beans.BusinessUserDataHibernate&lt;/managed-bean-class&gt;
          &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;
          &lt;managed-property&gt;
              &lt;property-name&gt;daoUserData&lt;/property-name&gt;
              &lt;value&gt;#{daoUserData}&lt;/value&gt;
          &lt;/managed-property&gt; 
      &lt;/managed-bean&gt;     
      &lt;managed-bean&gt;
          &lt;managed-bean-name&gt;daoUserData&lt;/managed-bean-name&gt;
          &lt;managed-bean-class&gt;org.data.source.DAOuserDataHibernate&lt;/managed-bean-class&gt;
          &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;
      &lt;/managed-bean&gt;
  </code></pre>
  
  <p><em>DAOuserDataHibernate.getUserData()</em> - which I am using as service class in BusinessUserDataHibernate class</p>
  
  <pre><code>     public UserData getUserData(String userName){
          sessionFactory = new Configuration().configure().buildSessionFactory();     
          UserData userData=null;
          try{
              session = sessionFactory.openSession();
              tx = session.beginTransaction();
              userData = (UserData)session.get(UserData.class, userName);
              tx.commit();            
                      session.close();
              return userData;
          }
          catch(HibernateException hEx){ return null; }                           
      }
  </code></pre>
  
  <p><em>hibernate.cfg.xml</em></p>
  
  <pre><code>&lt;hibernate-configuration&gt;
  
      &lt;session-factory&gt;
  
          &lt;!-- Database connection settings --&gt;
          &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
          &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/mySQLdb&lt;/property&gt;
          &lt;property name="connection.username"&gt;...&lt;/property&gt;
          &lt;property name="connection.password"&gt;...&lt;/property&gt;
  
          &lt;!-- JDBC connection pool (use the built-in) --&gt;
          &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
          &lt;!-- SQL dialect --&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
          &lt;!-- Disable the second-level cache  --&gt;
          &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt;
  
          &lt;!-- Echo all executed SQL to stdout --&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
          &lt;!-- Drop and create the database schema on startup --&gt;
          &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
  
          &lt;mapping resource="UserData.hbm.xml"/&gt;
  
      &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><em>UserData.hbm.xml</em></p>
  
  <pre><code>&lt;hibernate-mapping package="org.hibernate"&gt;
  
      &lt;class name="UserData" table="UserData"&gt;
          &lt;id name="userId" column="id" type="string"/&gt;
          &lt;property name="xmlData" type="clob"/&gt;
      &lt;/class&gt;
  
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>My imported jars</p>
  
  <p><a href="http://i.stack.imgur.com/BiCMk.jpg" rel="nofollow">http://i.stack.imgur.com/BiCMk.jpg</a></p>
  
  <p>When I run application in from as standalone test application it works fine (hibernate is picking data or writes to DB depending on DAO method I call). When I deploy it to WAR and run it on <em>Glasfish3</em> server it dumps</p>
  
  <p><em>Stack Trace</em></p>
  
  <pre><code>Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
      at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
      at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
      at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.&lt;init&gt;(EntityEntityModeToTuplizerMapping.java:56)
      at org.hibernate.tuple.entity.EntityMetamodel.&lt;init&gt;(EntityMetamodel.java:323)
      at org.hibernate.persister.entity.AbstractEntityPersister.&lt;init&gt;(AbstractEntityPersister.java:433)
      at org.hibernate.persister.entity.SingleTableEntityPersister.&lt;init&gt;(SingleTableEntityPersister.java:109)
      at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
      at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:231)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1313)
      at org.data.source.DAOuserHibernate.getAllUsers(DAOuserHibernate.java:61)
      at org.spring.beans.BusinessUserHibernate.getAllUsers(BusinessUserHibernate.java:33)
  </code></pre>
  
  <p>I tried different ways, also with Spring support but eventually I end up with this exception. It seems it is related somehow on building <em>sessionFactory</em>. Could you please help me in this matter.</p>
  
  <p>Thank you in advance
  Marcin</p>