aspose file tools*
The moose likes Object Relational Mapping and the fly likes Really strange error: Could not initialize class net.sf.hibernate.impl.SessionFactoryImpl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Really strange error: Could not initialize class net.sf.hibernate.impl.SessionFactoryImpl" Watch "Really strange error: Could not initialize class net.sf.hibernate.impl.SessionFactoryImpl" New topic
Author

Really strange error: Could not initialize class net.sf.hibernate.impl.SessionFactoryImpl

Rose Rimsky
Greenhorn

Joined: Feb 10, 2010
Posts: 25
Hi, I am newbie to Hibernate, and I was trying to implement it in a Java Web project that I had. Unfortunately, I am facing this mistake whenever I tried to run it:

java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.visit(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V

If I run it again, then I face this second error:

java.lang.NoClassDefFoundError: Could not initialize class net.sf.hibernate.impl.SessionFactoryImpl

I've been looking around for people facing this same error, but I haven't been lucky enough. Am I missing a jar? I'm using Hibernate 2, GlassFish v3, Java EE 5, Java Platform JDK 1.6., and Oracle 11g.

Here is my hibernate configuration:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:namedb</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">pass</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">10</property>
<!-- SQL dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</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">false</property>
</session-factory>
</hibernate-configuration>


And here is my log file (Sorry, it's a little long..):

[#|2010-02-11T00:38:18.948-0600|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=25;_ThreadName=httpSSLWorkerThread-8080-2;_RequestID=3970de56-24a5-4dc2-a7e4-a1c239ca94eb;|StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.visit(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at net.sf.cglib.ASMBackend.init(ASMBackend.java:83)
at net.sf.cglib.ASMBackend.begin_constructor(ASMBackend.java:296)
at net.sf.cglib.CodeGenerator.begin_constructor(CodeGenerator.java:281)
at net.sf.cglib.CodeGenerator.begin_constructor(CodeGenerator.java:274)
at net.sf.cglib.CodeGenerator.generateNullConstructor(CodeGenerator.java:970)
at net.sf.cglib.KeyFactoryGenerator.generate(KeyFactoryGenerator.java:105)
at net.sf.cglib.CodeGenerator.define(CodeGenerator.java:163)
at net.sf.cglib.KeyFactory.create(KeyFactory.java:114)
at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:318)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:613)
at org.apache.jsp.Summary_jsp._jspService(Summary_jsp.java from :122)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
|#]

[#|2010-02-11T00:38:22.598-0600|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=19;_ThreadName=httpSSLWorkerThread-8080-0;_RequestID=24fe38a2-79dc-4011-9423-b49e9cd06665;|StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError: Could not initialize class net.sf.hibernate.impl.SessionFactoryImpl
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:613)
at org.apache.jsp.Summary_jsp._jspService(Summary_jsp.java from :122)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
|#]

Would be great if someone could help me solve this problem. Any suggestion will be really helpful.

Thanks in advance!


Fairy tales are more than true: not because they tell us that dragons exist, but because they tell us that dragons can be beaten. – G.K. Chesterton
Christian Dillinger
Ranch Hand

Joined: Jul 20, 2009
Posts: 189
Do you *really* want to use a prehistoric version of Hibernate? Seems a little bit strange if you use JEE5, Java 6, GlassFish and Oracle 11... Or did you just find a tutorial written in the early twenties? ;-)
Rose Rimsky
Greenhorn

Joined: Feb 10, 2010
Posts: 25
Christian Dillinger wrote:Do you *really* want to use a prehistoric version of Hibernate? Seems a little bit strange if you use JEE5, Java 6, GlassFish and Oracle 11... Or did you just find a tutorial written in the early twenties? ;-)


Hi Christian, I was using Hibernate 3, but I was facing a problem with the Dialect (org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available) which I couldn't solve, so I decided to change to Hibernate 2, and that message seemed to stop , but then this new one appeared .
Christian Dillinger
Ranch Hand

Joined: Jul 20, 2009
Posts: 189


This is a sample hibernate.cfg.xml from one of my projects (it's using H2 as DB, but that doesn't matter). If you can switch back to Hibernate 3 and try again, post your error here and I think we can solve the problem.
Rose Rimsky
Greenhorn

Joined: Feb 10, 2010
Posts: 25
Christian Dillinger wrote:
This is a sample hibernate.cfg.xml from one of my projects (it's using H2 as DB, but that doesn't matter). If you can switch back to Hibernate 3 and try again, post your error here and I think we can solve the problem.


Hi, I changed the version to Hibernate 3 and then this error appeared: java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap.
So I just downloaded commons-collections-3.1.jar and everything seems to be working right .

Anyway, thanks for your help Christian!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Really strange error: Could not initialize class net.sf.hibernate.impl.SessionFactoryImpl