-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hi All
PostPosted: Sat Feb 20, 2010 3:58 am 
Newbie

Joined: Thu Feb 18, 2010 9:54 pm
Posts: 2
Iam getting below error when iam trying to run simple hibernate annotaion example

0 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.0.Beta-1
16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
16 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
156 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
156 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
156 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
281 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
281 [main] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
Initial SessionFactory creation failed.java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.roseindia.HibernateUtil.<clinit>(HibernateUtil.java:15)
at net.roseindia.Example1.main(Example1.java:11)
Caused by: java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings(AnnotationConfiguration.java:187)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1333)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at net.roseindia.HibernateUtil.<clinit>(HibernateUtil.java:11)
... 1 more

my bean class is

package net.roseindia;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "employee")
public class Employee implements Serializable {
public Employee() {

}
@Id
@Column(name = "id")
Integer id;

@Column(name = "name")
String name;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}

my 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>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</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">none</property>

<mapping class="net.roseindia.Employee"/>

</session-factory>
</hibernate-configuration>

my hibernateutil.java class is

package net.roseindia;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}

My business logic class is

package net.roseindia;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class Example1 {
public static void main(String[] args) throws Exception {
/** Getting the Session Factory and session */
SessionFactory session = HibernateUtil.getSessionFactory();
Session sess = session.getCurrentSession();
/** Starting the Transaction */
Transaction tx = sess.beginTransaction();
/** Creating Pojo */
Employee pojo = new Employee();
pojo.setId(new Integer(5));
pojo.setName("XYZ");
/** Saving POJO */
sess.save(pojo);
/** Commiting the changes */
tx.commit();
System.out.println("Record Inserted");
/** Closing Session */
session.close();
}



}


I used following jar files in classpath

C:\HibernateAnnotations\hibernate-annotations-3.4.0.GA\hibernate-annotations.jar

C:\HibernateAnnotations\hibernate-annotations-3.4.0.GA\lib\hibernate-commons-annotations.jar

C:\HibernateAnnotations\hibernate-annotations-3.4.0.GA\lib\test\jta.jar

C:\Hibernate\hibernate-distribution-3.5.0.Beta-1\hibernate3.jar

C:\Hibernate\hibernate-distribution-3.5.0.Beta-1\lib\required\antlr-2.7.6.jar

C:\Hibernate\hibernate-distribution-3.5.0.Beta-1\lib\required\commons-collections-3.1.jar

C:\Hibernate\hibernate-distribution-3.5.0.Beta-1\lib\required\dom4j-1.6.1.jar

C:\Hibernate\hibernate-distribution-3.5.0.Beta-1\lib\required\slf4j-api-1.5.8.jar

C:\MYSQL_Connector_J\mysql-connector-java-5.0.8\mysql-connector-java-5.0.8-bin.jar

C:\HibernateAnnotations\hibernate-annotations-3.4.0.GA\lib\ejb3-persistence.jar

C:\SLf4j\slf4j-1.5.8\slf4j-simple-1.5.8.jar


Top
 Profile  
 
 Post subject: Re: Hi All
PostPosted: Sat Feb 20, 2010 11:12 pm 
Newbie

Joined: Sun Feb 14, 2010 8:08 am
Posts: 12
I think there is compatible issues. https://www.hibernate.org/6.html has compatibility matrix where you can watch out.

PS: Pleas don'e use "Hi All" this is a forum, so ppl will b more happy to c issues's summary in the subject rather then "Hi All"


Top
 Profile  
 
 Post subject: Re: Hi All
PostPosted: Mon Feb 22, 2010 9:07 pm 
Newbie

Joined: Thu Feb 18, 2010 9:54 pm
Posts: 2
mpujari80
thanks.. my problem resloved. next time onwards i'll make sure to keep issue in subject tag.


Top
 Profile  
 
 Post subject: Re: Hi All
PostPosted: Wed Mar 24, 2010 8:23 am 
Newbie

Joined: Wed Mar 24, 2010 8:17 am
Posts: 1
Hello
I have the same problem but I can't acced to the page that you mention please give me the solution


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