• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

New to Hibernate.help with org.hibernate.HibernateException: Unable to instantiate default tuplizer  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am new to hibernate and am following the book, beginning hibernate from novice to profession by dave minter and jeff linwood.

I am trying to run the sample application from chapter 3 with mysql database. When I run it, I get the exception:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" 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.<init>(EntityEntityModeToTuplizerMapping.java:80)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:456)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at sample.PopulateMessages.main(PopulateMessages.java:13)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
... 9 more
Caused by: java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
at org.hibernate.bytecode.javassist.BytecodeProviderImpl.getProxyFactoryFactory(BytecodeProviderImpl.java:49)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactoryInternal(PojoEntityTuplizer.java:208)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:186)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:151)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:78)
... 14 more


My referenced libraries in eclipse are ant-1.6.2, dom4j-1.5.2, jta.jar, mysql-connector-java-5.0.3-bin, hibernate3, slf4j-api-1.5.2, log4j-1.2.15, slf4j-log4j12-1.5.2, common-collections-3.2.1 jars.


The src code is



package sample;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import sample.entity.Message;

public class PopulateMessages {
public static void main(String[] args) {
SessionFactory factory = new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();

session.beginTransaction();

Message m1 = new Message("Hibernated a message on " + new Date());
session.save(m1);

session.getTransaction().commit();

session.close();
}
}



package sample.entity;

public class Message {
private String message;


public Message() {
}

public Message(String message) {
this.message = message;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

}


Message.hbm.xml is
<?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 Aug 8, 2009 1:16:46 AM by Hibernate Tools 3.2.5.Beta -->
<hibernate-mapping>
<class name="sample.entity.Message" entity-name="Message" table="MESSAGE" proxy="sample.entity.Message">
<id type="int" column="id">
<generator class="native"/>
</id>
<property name="message" type="java.lang.String">
<column name="MESSAGE" />
</property>
</class>
</hibernate-mapping>



hibernate.cfg.xml is
<?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>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/eclipse</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.connection.pool_size">0</property>

<mapping resource="sample/entity/Message.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Any help in this regard shall be highly appreciated.

regards,
rahul
 
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I believe you need the javassist jar files.

http://jboss.org/javassist/downloads/

-Cameron McKenzie
 
Ak Rahul
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cameron.

I now get a different error:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [sample.entity.Message]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2176)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at sample.PopulateMessages.main(PopulateMessages.java:19)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'eclipse.message' doesn't exist
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3124)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1149)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
... 16 more

Any response in this regard shall be highly appreciated.

regards,
Rahul
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>eclipse.message

Looks like this table should exist in your database but does not.

-Cameron McKenzie
 
Ak Rahul
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cameron. It seems to be working fine now.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad I can help. Feel free to check out my signature links for a variety of very easy to follow tutorials on working with Hibernate. I know the book with which you are working, and while the information is solid, I did find the examples overly complex and fairly difficult to follow. I think I actually ran into exactly the same issues you are having.

Kindest regards,

-Cameron McKenzie
 
Ak Rahul
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cameron. I agree with you that the examples are a little complex. I shall go through your signature links.

Thanks again for your time.

regards,
Rahul
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cameron, big thanks!
 
Greenhorn
Posts: 1
Eclipse IDE MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Cameron Wallace McKenzie wrote:
I believe you need the javassist jar files.

http://jboss.org/javassist/downloads/

-Cameron McKenzie



Dear Sir,

I have the same PersistenceException Caused by HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
But I do have this library included in my build path:
$mvn dependency:tree ->
[INFO] [dependency:tree {execution: default-cli}]
[INFO] hibernate_autoformation:hibernate_autoformation:jar:0.1
[INFO] +- org.hibernate:hibernate:jar:3.2.7.ga:compile
[INFO] | +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] | +- commons-logging:commons-logging:jar:1.0.4:compile
[INFO] | +- asm:asm-attrs:jar:1.5.3:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- asm:asm:jar:1.5.3:compile
[INFO] | \- commons-collections:commons-collections:jar:2.1.1:compile
[INFO] +- javax.transaction:jta:jar:1.1:compile
[INFO] +- cglib:cglib:jar:2.2:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.4.0.GA:compile
[INFO] | +- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
[INFO] | +- org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:compile
[INFO] | +- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
[INFO] | +- org.hibernate:hibernate-core:jar:3.3.0.SP1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.4.2:compile
[INFO] +- jboss:jnp-client:jar:4.0.2:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.2:compile
[INFO] | \- log4j:log4j:jar:1.2.14:compile
[INFO] +- junit:junit:jar:4.8.2:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.14:compile
[INFO] \- javassist:javassist:jar:3.12.1.GA:compile

Hope you can help.
FYI, I'm trying to follow this tutorial: link
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!