-->
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.  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Initial SessionFactory creation failed
PostPosted: Sun Sep 20, 2009 3:35 am 
Newbie

Joined: Sun Sep 20, 2009 3:25 am
Posts: 11
SessionFactoryUtil.java

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


public class SessionFactoryUtil {

private static SessionFactory sessionFactory;

static {
try {
// Create the SessionFactory from hibernate.cfg.xml
// sessionFactory = new Configuration().configure().buildSessionFactory();
Configuration c= new Configuration();
c.configure();
sessionFactory = c.buildSessionFactory();



} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
ex.printStackTrace();
}
}

public static SessionFactory getSessionFactory()
{
return sessionFactory;
}

}


TestPerson.java

package com.sample;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;


public class TestPerson {

public static void main(String[] args) {
Session session = SessionFactoryUtil.getSessionFactory().getCurrentSession();

session.beginTransaction();

createPerson(session);

queryPerson(session);

}

private static void queryPerson(Session session) {
Query query = session.createQuery("from person");
List <person>list = query.list();
java.util.Iterator<person> iter = list.iterator();
while (iter.hasNext()) {

person person = iter.next();
System.out.println("Person: \"" + person.getName() +
"\", " + person.getAge());

}

session.getTransaction().commit();

}

public static void createPerson(Session session) {
person person = new person();

person.setName("Barak");
person.setAge("91");

session.save(person);
}
}



I am finding a strange error...

Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:120)
at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:16)
at com.sample.TestPerson.main(TestPerson.java:11)
Exception in thread "main" java.lang.NullPointerException
at com.sample.TestPerson.main(TestPerson.java:11)..

I have included most of the lib files needed.

please help me to fix the problem..
Thanks in advance.........
BUBI


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Sun Sep 20, 2009 3:48 am 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi BUBI,

I don't think
Quote:
I have included most of the lib files needed.
will do it. You will need to include all libs that you use.

In your case you are missing Apache's commons-logging.jar in your class path. If you don't have it at all you might get it from http://commons.apache.org/logging/guide.html

CU
Froestel

P.S.: It would be much easier to read your code if you'd enclose it in the BBCode Code-Tags. See the buttons below the subject field.

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


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Sun Sep 20, 2009 7:07 am 
Newbie

Joined: Sun Sep 20, 2009 3:25 am
Posts: 11
Froestel,
Thanks for your reply.I enclosed the same earlier code in BBCode block as you have said.

The jar files I am using are:

hibernate3.jar

slf4j-api-1.5.2.jar

antlr-2.7.6.jar

commons-collections-3.1.jar

dom4j-1.6.1.jar

javassist-3.4.GA.jar

jta-1.1.jar.

probably you are talking about this commons-collections-3.1.jar.Its already included in my project.Please let me know if you can fix the problem.

Thanks in advance
BUBI..


Code:
SessionFactoryUtil.java

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


public class SessionFactoryUtil {

private static SessionFactory sessionFactory;

static {
try {
// Create the SessionFactory from hibernate.cfg.xml
// sessionFactory = new Configuration().configure().buildSessionFactory();
Configuration c= new Configuration();
c.configure();
sessionFactory = c.buildSessionFactory();



} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
ex.printStackTrace();
}
}

public static SessionFactory getSessionFactory()
{
return sessionFactory;
}

}


TestPerson.java

package com.sample;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;


public class TestPerson {

public static void main(String[] args) {
Session session = SessionFactoryUtil.getSessionFactory().getCurrentSession();

session.beginTransaction();

createPerson(session);

queryPerson(session);

}

private static void queryPerson(Session session) {
Query query = session.createQuery("from person");
List <person>list = query.list();
java.util.Iterator<person> iter = list.iterator();
while (iter.hasNext()) {

person person = iter.next();
System.out.println("Person: \"" + person.getName() +
"\", " + person.getAge());

}

session.getTransaction().commit();

}

public static void createPerson(Session session) {
person person = new person();

person.setName("Barak");
person.setAge("91");

session.save(person);
}
}



I am finding a strange error...

Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:120)
at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:16)
at com.sample.TestPerson.main(TestPerson.java:11)
Exception in thread "main" java.lang.NullPointerException
at com.sample.TestPerson.main(TestPerson.java:11)..


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Sun Sep 20, 2009 10:41 am 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi BUBI,

Quote:
probably you are talking about this commons-collections-3.1.jar.


No, I wasn't talking about this package, I was explicitly writing commons-logging.jar. You will require to have it in your class path. If it's not there you can get it from the location I mentioned in my previous post.

This library is used by Hibernate to create logging output, i.e. to log files or the console.

CU
Froestel

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


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Sun Sep 20, 2009 2:38 pm 
Newbie

Joined: Sun Sep 20, 2009 3:25 am
Posts: 11
hi,
thank you so much for your reply.I have added the commons-logging-1.1.1jar file in my class path.But now I am getting the errors as..

Sep 21, 2009 12:00:47 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.4.sp1
Sep 21, 2009 12:00:47 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Sep 21, 2009 12:00:47 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Sep 21, 2009 12:00:47 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Sep 21, 2009 12:00:48 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Sep 21, 2009 12:00:48 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Sep 21, 2009 12:00:48 AM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: /hibernate.cfg.xml(2) Content is not allowed in prolog.
Initial SessionFactory creation failed.org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:17)
at com.sample.TestPerson.main(TestPerson.java:11)
Caused by: org.dom4j.DocumentException: Error on line 2 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
... 4 more
Exception in thread "main" java.lang.NullPointerException
at com.sample.TestPerson.main(TestPerson.java:11)

Please help me out in fixing the problem.I am a beginner in hibernate application.My code was attached previously in BBCode as you have said.I append herewith the hibernate.cfg.xml file.....& ....Person.hbm.xml

Code:
//hibernate.cfg.xml
<?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> 
   
     <!-- hibernate dialect --> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> 
   
       
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.url">jdbc:MySQL://127.0.0.1:3306/mysql</property> 
     <property name="hibernate.connection.username">root</property> 
     <property name="hibernate.connection.password"></property> 
     <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 
       
     <!-- Automatic schema creation (begin) === -->       
     <property name="hibernate.hbm2ddl.auto">create</property> 
   
       
     <!-- Simple memory-only cache --> 
     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> 
   
      <!-- Enable Hibernate's automatic session context management --> 
      <property name="current_session_context_class">thread</property> 
   
     <!-- ############################################ --> 
     <!-- # mapping files with external dependencies # --> 
     <!-- ############################################ --> 
   
   
     <mapping resource="com/sample/Person.hbm.xml"/> 
   
</session-factory> 
</hibernate-configuration>


//Person.hbm.xml
<?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="sample.hibernate.Person" table="Person"> 
   
         <id name="id" column="ID"> 
             <generator class="native" /> 
         </id> 
   
         <property name="name"> 
             <column name="NAME" length="16" not-null="true" /> 
         </property> 
         
         <property name="age"> 
            <column name="AGE" length="16" not-null="true" /> 
         </property> 
   
     </class> 
</hibernate-mapping>




Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Sun Sep 20, 2009 2:51 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi BUBI,

looks like there might be problems with your hibernate.cfg.xml in two places (I shortened it a bit):
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>
     ...
     <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
       
    ....

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

The names of both properties I left in the above snippet should start with hibernate. (like all the others do, too). So change these two property elements to look like this
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>
     ...
     <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
       
    ....

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

That's all I see for now.

CU
Froestel

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


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Sun Sep 20, 2009 3:31 pm 
Newbie

Joined: Sun Sep 20, 2009 3:25 am
Posts: 11
Hi Froestel,
Thanks for your kind perusal.I have changed the property in session-factory by adding hibernate as you have said.The changed hibernate.cfg.xml file looks like

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> 
   
     <!-- hibernate dialect --> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> 
   
       
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.url">jdbc:MySQL://127.0.0.1:3306/mysql</property> 
     <property name="hibernate.connection.username">root</property> 
     <property name="hibernate.connection.password"></property> 
     <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 
       
     <!-- Automatic schema creation (begin) === -->       
     <property name="hibernate.hbm2ddl.auto">create</property> 
   
       
     <!-- Simple memory-only cache --> 
     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> 
   
      <!-- Enable Hibernate's automatic session context management --> 
      <property name="hibernate.current_session_context_class">thread</property> 
   
     <!-- ############################################ --> 
     <!-- # mapping files with external dependencies # --> 
     <!-- ############################################ --> 
   
   
     <mapping resource="com/sample/Person.hbm.xml"/> 
   
</session-factory> 
</hibernate-configuration> 


But still the error remains..It shows..


Sep 21, 2009 12:57:54 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.4.sp1
Sep 21, 2009 12:57:54 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Sep 21, 2009 12:57:54 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Sep 21, 2009 12:57:54 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Sep 21, 2009 12:57:54 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Sep 21, 2009 12:57:54 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Sep 21, 2009 12:57:55 AM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: /hibernate.cfg.xml(2) Content is not allowed in prolog.
Initial SessionFactory creation failed.org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:17)
at com.sample.TestPerson.main(TestPerson.java:11)
Caused by: org.dom4j.DocumentException: Error on line 2 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
... 4 more
Exception in thread "main" java.lang.NullPointerException
at com.sample.TestPerson.main(TestPerson.java:11).

Thanks once again for your earnest support.
BUBI


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Sun Sep 20, 2009 7:09 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi BUBI,

your stack trace contains:
Quote:
Caused by: org.dom4j.DocumentException: Error on line 2 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.


As far as I can see there is a "<" sign missing before !DOCTYPE so the DTD should read:
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>
...
</hibernate-configuration>


CU
Froestel

P.S.: If you'd use an IDE, i.e. Eclipse, with the Hibernate Tools (see https://www.hibernate.org/255.html ) installed the editor should provide you with info on errors, esp. sytnax errors. Otherwise you might probably use an XML editor of your choice. The error is an XML-syntax error and this should not make you post in a forum nowadays.

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


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Mon Sep 21, 2009 1:49 am 
Newbie

Joined: Sun Sep 20, 2009 3:25 am
Posts: 11
Hi Froestel,
I am so sorry for asking you to fix a syntax error.I should have been aware of that.
Neways after fixing the syntax prolem and all,I am still unable to get the desired output.
The hibernate.cfg.xml looks like....
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> 
   
     <!-- hibernate dialect --> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> 
   
       
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.url">jdbc:MySQL://127.0.0.1:3306/mysql</property> 
     <property name="hibernate.connection.username">root</property> 
     <property name="hibernate.connection.password"></property> 
     <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 
       
     <!-- Automatic schema creation (begin) === -->       
     <property name="hibernate.hbm2ddl.auto">create</property> 
   
       
     <!-- Simple memory-only cache --> 
     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> 
   
      <!-- Enable Hibernate's automatic session context management --> 
      <property name="hibernate.current_session_context_class">thread</property> 
   
     <!-- ############################################ --> 
     <!-- # mapping files with external dependencies # --> 
     <!-- ############################################ --> 
   
   
     <mapping resource="com/sample/Person.hbm.xml"/> 
   
</session-factory> 
</hibernate-configuration> 


The file person.hbm.xml looks like....
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="com.sample.person" table="Person"> 
   
         <id name="name" column="name"> 
             <generator class="native" /> 
         </id> 
   
         <property name="name"> 
             <column name="NAME" length="16" not-null="true" /> 
         </property> 
         
         <property name="age"> 
            <column name="AGE" length="16" not-null="true" /> 
         </property> 
   
     </class> 
</hibernate-mapping>


The error I am getting is..
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.4.sp1
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : com/sample/Person.hbm.xml
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.sample.person -> Person
Sep 21, 2009 11:15:58 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Sep 21, 2009 11:15:58 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Sep 21, 2009 11:15:58 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Sep 21, 2009 11:15:58 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Sep 21, 2009 11:15:58 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:MySQL://127.0.0.1:3306/mysql
Sep 21, 2009 11:15:58 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.51b-community-nt
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.8 ( Revision: ${svn.Revision} )
Sep 21, 2009 11:15:59 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
Sep 21, 2009 11:15:59 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
Sep 21, 2009 11:15:59 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Sep 21, 2009 11:15:59 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.HashtableCacheProvider
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Sep 21, 2009 11:15:59 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
Sep 21, 2009 11:15:59 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
at org.hibernate.bytecode.cglib.BytecodeProviderImpl.getProxyFactoryFactory(BytecodeProviderImpl.java:33)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactoryInternal(PojoEntityTuplizer.java:182)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:160)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:18)
at com.sample.TestPerson.main(TestPerson.java:11)
Exception in thread "main" java.lang.NullPointerException
at com.sample.TestPerson.main(TestPerson.java:11)

Thanks in advance for your support
BUBI


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Mon Sep 21, 2009 11:57 am 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi BUBI,

Quote:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter

Hibernate is missing the Code Generation Library cglib. Ensure that you have a cglib-<version-number>.jar in your classpath. It ships with Hibernate (in the lib folder). If it's not there you should be able to get it from SourceForge.

CU
Froestel

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


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Mon Sep 21, 2009 1:56 pm 
Newbie

Joined: Sun Sep 20, 2009 3:25 am
Posts: 11
Hi Froestel,

Thank you so much for your reply.It has now got no problem with the SessionFactory.But I found a strange error...

Sep 21, 2009 11:11:11 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
Sep 21, 2009 11:11:12 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
Sep 21, 2009 11:11:12 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
Sep 21, 2009 11:11:12 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
/*foo*/ select * from ( select rownumber() over() as rownumber_, * from foos ) as temp_ where rownumber_ between ?+1 and ?
/*foo*/ select * from ( select rownumber() over() as rownumber_, row_.* from ( select distinct * from foos ) as row_ ) as temp_ where rownumber_ between ?+1 and ?
/*foo*/ select * from ( select rownumber() over(order by foo.bar, foo.baz) as rownumber_, * from foos foo order by foo.bar, foo.baz ) as temp_ where rownumber_ between ?+1 and ?
/*foo*/ select * from ( select rownumber() over() as rownumber_, row_.* from ( select distinct * from foos foo order by foo.bar, foo.baz ) as row_ ) as temp_ where rownumber_ between ?+1 and ?

Please help me out to fix the problem.I am actually a beginner in hibernate.Thanks a ton for your earnest support.

Thanking you
BUBI


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Mon Sep 21, 2009 2:09 pm 
Senior
Senior

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

I cannot see a problem - is there any error notification or stack trace you probably left out? This looks very much like standard log entries of Hibernate - although I've never seen these /*foo*/ thingies. Does this come from your code?

CU
Froestel

P.S.: As a beginner you should at first work yourself through the Hibernate documentation (to be found at http://docs.jboss.org/hibernate/stable/core/reference/en/html/). When you are done with that you should be able to solve most of your problems by yourself. You might also get yourself one of those excellent Hibernate books out there and spend a couple of days reading. This should make a lot of things clearer.

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


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Mon Sep 21, 2009 2:27 pm 
Newbie

Joined: Sun Sep 20, 2009 3:25 am
Posts: 11
Hi,
Thanks for your link to the documentation.
Actually when I am running the application in eclipse,I got these "foo" stuffs in the console....

/*foo*/ select * from ( select rownumber() over() as rownumber_, * from foos ) as temp_ where rownumber_ between ?+1 and ?
/*foo*/ select * from ( select rownumber() over() as rownumber_, row_.* from ( select distinct * from foos ) as row_ ) as temp_ where rownumber_ between ?+1 and ?
/*foo*/ select * from ( select rownumber() over(order by foo.bar, foo.baz) as rownumber_, * from foos foo order by foo.bar, foo.baz ) as temp_ where rownumber_ between ?+1 and ?
/*foo*/ select * from ( select rownumber() over() as rownumber_, row_.* from ( select distinct * from foos foo order by foo.bar, foo.baz ) as row_ ) as temp_ where rownumber_ between ?+1 and ?Sep 21, 2009 11:55:57 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
Sep 21, 2009 11:55:58 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
Sep 21, 2009 11:55:58 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
Sep 21, 2009 11:55:58 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect

Thanks for your support
BUBI


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Mon Sep 21, 2009 3:38 pm 
Newbie

Joined: Sun Sep 20, 2009 3:25 am
Posts: 11
Hi Froestel,
The strange errors ultimately removed...But it was replaced by another errors.

Let me first tell you the jar files I am using are...

mysql.jar
slf4j-api-1.5.2.jar
slf4j-jdk14-1.5.2.jar
hibernate3.jar
dom4j-1.6.1.jar
javassist-3.4.ga.jar
commons-collections-3.2.1.jar
jta-1.1.jar
antlr-2.7.6.jar
commons-logging-1.1.1.jar
cglib-2.2.jar.

Now the files are..

Code:
   

///TestPerson.java

package com.sample; 
   
    import java.util.List; 
    import org.hibernate.Query; 
    import org.hibernate.Session; 

     
   public class TestPerson { 
       
       public static void main(String[] args) { 
        Session session = SessionFactoryUtil.getSessionFactory().getCurrentSession(); 
       
        session.beginTransaction(); 
     
            createPerson(session); 
             
            queryPerson(session); 
     
           } 
     
       private static void queryPerson(Session session) { 
            Query query = session.createQuery("from person");                   
            List <person>list = query.list(); 
           java.util.Iterator<person> iter = list.iterator(); 
           while (iter.hasNext()) { 
             
              person person = iter.next(); 
            System.out.println("Person: \"" + person.getName() + 
                            "\", " + person.getAge()); 
   
            } 
           
            session.getTransaction().commit(); 
             
       } 
     
      public static void createPerson(Session session) { 
         person person = new person(); 
     
            person.setName("Barak");     
            person.setAge("91");         
             
            session.save(person); 
       } 
   }

//person.java

package com.sample;
import java.lang.*;

public class person { 
        String name; 
        String age; 
        private Long id;


          
       public Long getId() {
            return id;
        }

        private void setId(Long id) {
            this.id = id;
        }

        public String getName()
        { 
            return name; 
        } 
        public void setName(String name)
        { 
            this.name = name; 
        } 
          
        public String getAge()
        { 
            return age; 
        } 
        public void setAge(String age)
        { 
            this.age = age; 
        } 
    } 

   
///SessionFactoryUtil.java

package com.sample; 
     
   import org.hibernate.Session; 
   import org.hibernate.SessionFactory; 
   import org.hibernate.cfg.Configuration; 
     
     
    public class SessionFactoryUtil { 
     
        private static  SessionFactory sessionFactory; 
     
          static { 
              try { 
                  // Create the SessionFactory from hibernate.cfg.xml 
                  // sessionFactory = new Configuration().configure().buildSessionFactory(); 
                 Configuration c= new Configuration();
                  c.configure();
                  sessionFactory = c.buildSessionFactory();
             
             
             
              } catch (Throwable ex) { 
                 // Make sure you log the exception, as it might be swallowed 
                 System.err.println("Initial SessionFactory creation failed." + ex); 
                  ex.printStackTrace();
              } 
           } 
     
           public static SessionFactory getSessionFactory()
           { 
               return sessionFactory; 
           } 
     
  } 

//Person.hbm.xml

<?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="com.sample.person" table="Person"> 
   
         <id name="name" column="name"> 
             <generator class="native" /> 
         </id> 
   
         <property name="name"> 
             <column name="NAME" length="16" not-null="true" /> 
         </property> 
         
         <property name="age"> 
            <column name="AGE" length="16" not-null="true" /> 
         </property> 
   
     </class> 
</hibernate-mapping>


///hibernate.cfg.xml

<?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> 
   
     <!-- hibernate dialect --> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> 
   
       
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.url">jdbc:MySQL://127.0.0.1:3306/mysql</property> 
     <property name="hibernate.connection.username">root</property> 
     <property name="hibernate.connection.password"></property> 
     <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 
       
     <!-- Automatic schema creation (begin) === -->       
     <property name="hibernate.hbm2ddl.auto">update</property> 
   
       
     <!-- Simple memory-only cache --> 
     <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> 
   
      <!-- Enable Hibernate's automatic session context management --> 
      <property name="hibernate.current_session_context_class">thread</property> 
   
     <!-- ############################################ --> 
     <!-- # mapping files with external dependencies # --> 
     <!-- ############################################ --> 
   
   
     <mapping resource="com/sample/Person.hbm.xml"/> 
   
</session-factory> 
</hibernate-configuration> 




The error I am getting is...
Sep 22, 2009 1:03:21 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.4.sp1
Sep 22, 2009 1:03:21 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Sep 22, 2009 1:03:21 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Sep 22, 2009 1:03:21 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Sep 22, 2009 1:03:21 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Sep 22, 2009 1:03:21 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Sep 22, 2009 1:03:21 AM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : com/sample/Person.hbm.xml
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.sample.person -> Person
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Sep 22, 2009 1:03:22 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Sep 22, 2009 1:03:22 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Sep 22, 2009 1:03:22 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Sep 22, 2009 1:03:22 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:MySQL://127.0.0.1:3306/mysql
Sep 22, 2009 1:03:22 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.51b-community-nt
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.8 ( Revision: ${svn.Revision} )
Sep 22, 2009 1:03:22 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
Sep 22, 2009 1:03:22 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
Sep 22, 2009 1:03:22 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Sep 22, 2009 1:03:22 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.HashtableCacheProvider
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Sep 22, 2009 1:03:22 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
Sep 22, 2009 1:03:23 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/objectweb/asm/Type
java.lang.NoClassDefFoundError: org/objectweb/asm/Type
at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)
at net.sf.cglib.core.KeyFactory.<clinit>(KeyFactory.java:66)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:18)
at com.sample.TestPerson.main(TestPerson.java:11)
Exception in thread "main" java.lang.NullPointerException
at com.sample.TestPerson.main(TestPerson.java:11)

Please let me know if you find any solution.
Thanks in advance
BUBI


Top
 Profile  
 
 Post subject: Re: Initial SessionFactory creation failed
PostPosted: Mon Sep 21, 2009 4:02 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi BUBI,

this is your error information:
Code:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/objectweb/asm/Type
java.lang.NoClassDefFoundError: org/objectweb/asm/Type
at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)
at net.sf.cglib.core.KeyFactory.<clinit>(KeyFactory.java:66)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:18)
at com.sample.TestPerson.main(TestPerson.java:11)
Exception in thread "main" java.lang.NullPointerException
at com.sample.TestPerson.main(TestPerson.java:11)

The error is quite similar to the previous one with cglib. You are missing a library jar. I guess in the meantime you can easily figure out which one it is.

Please - I cannot spend my time on helping you with issues that are actually less Hibernate than Java related. The above stack trace should give you enough information to solve the problem on your own (or are you new to Java as well?). There are lots of search engines, forums, documentation, books, and much more out there. Find it, use it.

It is your project and you have to deal with it. If you spent a couple of days searching for a solution without any success then it is time to post to a forum. I won't keep on doing all your work. It takes some time to get acquainted with Hibernate and there will be a lot of reading, testing, searching, and so on. I'm not talking about days or weeks here...

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.  [ 20 posts ]  Go to page 1, 2  Next

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.