-->
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.  [ 3 posts ] 
Author Message
 Post subject: ExceptionInInitializerError Caused by:ClassCastException
PostPosted: Wed Jan 17, 2007 6:04 am 
Newbie

Joined: Tue Jan 16, 2007 11:01 pm
Posts: 8
I just want to write a test example using Hibernate , but error occurred as below
Hibernate version:
Hibernate 2.1.8 , for some reasons , i must use this low hibernate edition.
Mapping documents:
hibernate.cfg.xml:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.password">******</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

<property name="show_sql">True</property>
<property name="hibernate.use_outer_join">True</property>
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<mapping resource="book.hbm.xml"/>
</session-factory>
</hibernate-configuration>

book.hbm.xml:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 1.1//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="org.test.book.services.db.Book" table="book_book">
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<property name="name" type="string">
<column name="name" length="100" />
</property>
<property name="author" type="string">
<column name="author" length="100" />
</property>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Session session=new Configuration().configure().buildSessionFactory().openSession(); //the point error occurs!!!!!!!!!!!!!
Book addedbook=new Book();
tx=session.beginTransaction();
session.save(addedbook);
tx.commit();
Full stack trace of any exception that occurs:
java.lang.ExceptionInInitializerError
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at org.test.book.services.db.BookUtil.add(BookUtil.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at

javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

(ApplicationFilterChain.java:252) at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.gridlab.gridsphere.filters.GridSphereFilter.doFilter(GridSphereFilter.java:77) at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

(ApplicationFilterChain.java:202) at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at

org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at

org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at

org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection

(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket

(PoolTcpEndpoint.java:527) at

org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt

(LeaderFollowerWorkerThread.java:80) at

org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at

java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassCastException:

net.sf.hibernate.impl.SessionFactoryImpl$QueryCacheKeyFactory$$KeyFactoryByCGLIB$$601120e

d
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:237)
... 44 more
Name and version of the database you are using:
Mysql 5.0.18


-_-! Waiting for your help ..........


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 9:06 pm 
Newbie

Joined: Tue Jan 16, 2007 11:01 pm
Posts: 8
i guess maybe sth wrong with my cfg.xml ? anyone can help me?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 2:10 am 
Newbie

Joined: Tue Jan 16, 2007 11:01 pm
Posts: 8
That 's an emergency , sorry for my mutil posting .............


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.