• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session creation falied - error

 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to create a session in Hibernate. I am using


with all the jar in place and no other error coming. I have put this code in a servlet. The whole code goes like this.

I am getting error


HibernateUtil class is


The configuration xml file is hibernate.cfg.xml



What I am doing wrongly, please someone help me here.

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the error message say? Do you have a stack trace you can post?
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no stack trace this is what I am getting in the console -

the test string(Sys.out code that I am putting on the top of the TestHibernate servlet) followed by the error message -
Initial SessionFactory creation failed.java.lang.IncompatibleClassChangeError



Hope this helps. Please ask me for more details.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a deployment issue. Clear down your container's temporary directories and redeploy you application.
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giffy Geraldo wrote:



change the above to

for a full stack trace.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok you meant



Thanks. I am trying these options.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the stack trace.

 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a link to similar problem
http://www.coderanch.com/t/218728/Object-Relational-Mapping/java/IncompatibleClassChangeError

So I tried with different options - earlier I was putting the hibernate.cfg.xml in the app folder only. Now I have moved it to classes folder. I dun know why is that? I was following a youtube video to create a hibernate project, earlier by not putting it in the classes folder.

now it seems the classChnageError is gone.

Would some one please help me understand how to deplpy these config xmls, log4j.prop files etc for hibernate application. TIA.

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So I tried with different options - earlier I was putting the hibernate.cfg.xml in the app folder only. Now I have moved it to classes folder. I dun know why is that? I was following a youtube video to create a hibernate project, earlier by not putting it in the classes folder.

"app folder", what do you mean by that? If you are deploying a web application you need to include the Hibernate configuration file on the classpath. If you are using the default configuration this need to be at the root of your classpath. Web applications have specified folders* that are included in the classpath. If you don't use these it will be up to how you configure your servlet container's classloader to pick dependent files up.

However, an IncompatibleClassChangeError is not what I would expect if you had put hibernate.cfg.xml in the wrong place. An erro like that usually only happens as the result of hot deployment.

*(If this is something you were not aware of I would go through the servlet parts of this before trying anything more with Hibernate)
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for quick response.

Thanks Paul for pointing that out. However I have one more query related to the directory structure and places where you need to put the various descriptors, context files etc. If we are using Eclipse as IDE - will the package hierarchy be same for Netbeans IDE. I am not sure of this thing. But I remember one time I was not able to run the application: set up in Eclipse and running properly, in Netbeans. Please help me understand this. TIA
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However I have one more query related to the directory structure and places where you need to put the various descriptors, context files etc. If we are using Eclipse as IDE - will the package hierarchy be same for Netbeans IDE.


Placing those descriptors, config files in standard places matters when you deploy in an application server/running as a standalone app etc.. and not with development. Different IDEs use different folder hierarchies when we create projects (web,Java projects etc...). But the IDE will package the fles in a way that can be run (and accepted) in an application server (for web projects etc..). We can even use our own hierarchies and build the output files (to be run in a server/standalone) by using build tools like Ant inside the IDEs.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic